当前位置导航:炫浪网>>网络学院>>网页制作>>ASP.NET教程

LINQ 实现常见SQL查询

欢迎进入.NET社区论坛,与200万技术人员互动交流 >>进入

 

    1.Top 查询----skip(index).Take(count)

      var Results = from dt in ctx.Customers.Skip(0).Take(10)
                              select new
                              ...{
                                  dt.CustomerID,
                                  dt.CompanyName,
                                  dt.City
                              };

    2.Like 查询----startwith()
               from dt in ctx.Customers
               where dt.ID.Startwith('A')

    3.In查询----Contain()
      string[] s = ...{ "ivan","aaa","aaaa"};
                var Results = from dt in ctx.Customers.Skip(0).Take(10)
                              where s.Contains(dt.CustomerID)
                              select new
                              ...{
                                  dt.CustomerID,
                                  dt.CompanyName,
                                  dt.City
                              };

相关内容
赞助商链接