码迷,mamicode.com
首页 > 其他好文 > 详细

Linq To EF

时间:2015-08-18 18:17:20      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:

l简单查询:
var result = from c in Entities.Customer select c;
l条件查询:

  普通linq写法: var result = from c in Entities.Customer where c.Gender ==‘w’ select c;

  Lambda表达式写法:   var result = from c in Entities.Customer.Where<Customer>(c =>c.Gender==‘w’);

         排序分页写法: IQueryable<Customers> cust10 = (from c in customers

l                                         orderby c.CustomerID
l                                         select c).Skip(0).Take(10);
 
l左外连接:可以的连接有Join 和 GroupJoin 方法。GroupJoin组联接等效于左外部联接,它返回第一个(左侧)数据源的每个元素(即使其他数据源中没有关联元素)。
l var query = from d in edm.Order_Details
l                   join order in edm.Orders
l                   on d.OrderID equals order.OrderID
l                   select new
l                    {
l                        OrderId = order.OrderID,
l                        ProductId = d.ProductID,
l                        UnitPrice = d.UnitPrice

Linq To EF

标签:

原文地址:http://www.cnblogs.com/hsha/p/4739715.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!