[英]Linq: SqlFunctions.PatIndex vs string.Contains for string comparisson
Which of the following versions for the same query will perform better: 相同查询的以下哪个版本的性能会更好:
Version 1 (string.Contains): 版本1(string.Contains):
var query = db.Products
.Where( p => p.Description.Contains( description ) );
Version 2 ( SqlFunctions.PatIndex ): 版本2(SqlFunctions.PatIndex):
var query = db.Products
.Where( p => SqlFunctions.PatIndex("%" + description + "%",p.Description) > 0 );
I believe version 1 runs faster theoretically. 我相信版本1在理论上运行得更快。
Reasons: 原因:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.