Reputation: 15
I have a query
select Max(CompanyId) from EmployeeCompany where CompanyId like '01-001' +'-___'
How can I implement '___' in Linq any idea? I have companiyId like 01-001-111, 01-001-112
Upvotes: 0
Views: 159
Reputation: 236328
With Entity Framework you can use SqlFunctions.PatIndex
db.EmployeeCompany
.Where(c => SqlFunctions.PatIndex("01-001-___", c.CompanyId) > 0)
.Max(c => CompanyId)
NOTE: This function will not generate SQL query with LIKE operator. Instead it will generate query with PATINDEX function (which seems to be faster than LIKE operator).
Upvotes: 2