linq的join
简单查询:var result = from c in Entities.Customer select c;
条件查询:
普通linq写法: var result = from c in Entities.Customer where c.Gender ‘w’ select c;
Lambda表达式写法: var result = from c in Entities.Customer.Where
排序分页写法: IQueryable
orderby c.CustomerID
select c).Skip(0).Take(10);
左外连接:可以的连接有Join 和 GroupJoin 方法。GroupJoin组联接等效于左外部联接,它返回第一个(左侧)数据源的每个元素(即使其他数据源中没有关联元素)。
var query = from d in edm.Order_Details
join order in edm.Orders
on d.OrderID equals order.OrderID
select new
{
OrderId = order.OrderID,
ProductId = d.ProductID,
UnitPrice = d.UnitPrice