Thursday, August 22, 2013

LinqToSQL: How To do a equivalent of Like '%' "Match Everything"

Question:

How can I do a equivalent of LIKE '%' in SQL with LinqToSql?

Answer:

Simply pass an empty string "" to Contains function.

For example,

var patients = from p in ctx.Patients where PatientsName.Contains("");


No comments: