LINQ中怎么使用LIKE方法?

0 star

linq怎么用SQL中的LIKE方法呢?

2 回答

0

linq有个SqlMethods静态类,它里面就有提供like方法,你可以看下

永久链接
0

var result = from o in db.Orders
     join od in db.Order_Details on o.OrderID equals od.OrderID
     where SqlMethods.Like(o.ShipCountry, txtKeyWord.Text)
             select new newItem
             {
                 rderID = o.OrderID,
                 CustomerID = o.CustomerID,
                 ShipName = o.ShipName,
                 ShipCity = o.ShipCity,
                 ShipCountry = o.ShipCountry,
                 UnitPrice = od.UnitPrice,
                 Quantity = od.Quantity
             };

永久链接