LINQ中怎么使用LIKE方法?

标签: Linq
发布时间: 2010/7/25 16:08:43

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

解决方法 1:

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

解决方法 2:

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
             };

官方微信
官方QQ群
31647020