linq like查询语句范例
Admin | 2018-8-29 15:14:31 | 被阅次数 | 3761
一、单一条件查询
var expr = context.Products.Where(p => p.ProductName == "LINQ to SQL");
二、组合条件查询
var expr = context.Products.Where(p => p.ProductName == "LINQ to SQL" && p.UnitPrice > 10m);
三、Like查询
var expr = from p in context.Products
where p.ProductName.StartsWith("LINQ")
select new { p.ProductID, p.ProductName };
var expr = from p in context.Products
where p.ProductName.EndsWith("LINQ")
select new { p.ProductID, p.ProductName };
var expr = from p in context.Products
where p.ProductName.Contains("LINQ")
select new { p.ProductID, p.ProductName };