linq WHERE
1.简单形式:
var q = from c in db.Customers where c.City == "London" select c;
var q = from e in db.Employees where e.HireDate >= new DateTime(1994, 1, 1) select e;
2.关系条件形式:
var q = from p in db.Products where p.UnitsInStock <= p.ReorderLevel && !p.Discontinued select p;
var q = from p in db.Products where p.UnitPrice > 10m || p.Discontinued select p;
//这里要看看。如果实现了接口的话。就可以用了,主要是说OBJECT。
var q =
db.Products.Where(p=>p.UnitPrice > 10m).Where(p=>p.Discontinued);
3.First()形式:
返回集合中的一个元素,其实质就是在SQL语句中加TOP (1)
Shipper shipper = db.Shippers.First();
Customer cust = db.Customers.First(c => c.CustomerID == "BONAP");
Order ord = db.Orders.First(o => o.Freight > 10.00M);