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(c =>c.Gender
‘w’);
排序分页写法: IQueryable cust10 = (from c in customers
                                         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

posted on 2015-02-23 16:23  木屐  阅读(120)  评论(0编辑  收藏  举报

导航