Which of the following versions for the same query will perform better:
Version 1 (string.Contains):
var query = db.Products
.Where( p => p.Description.Contains( description ) );
Version 2 ( SqlFunctions.PatIndex ):
var query = db.Products
.Where( p => SqlFunctions.PatIndex("%" + description + "%",p.Description) > 0 );
I believe version 1 runs faster theoretically.
Reasons:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.