Friday, August 16, 2013

Linq to SQL Like Operator

Linq to SQL Like Operator:

 Using String.StartsWith or String.Endswith

var query = from c in Customers
            where c.City.StartsWith("Lo")
            select c;

var query = from c in Customers
            where c.City.StartsWith("L") && c.City.Contains("n")
            select c;

var query = from c in ctx.Customers
            where SqlMethods.Like(c.City, "L_n%")

            select c; 

No comments:

Post a Comment