有风的日子

Miss Wendy Days

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
子查询

描述:查询订单数超过5的顾客信息

查询句法:

var 子查询 = from c in ctx.Customers

                   where

                       (from o in ctx.Orders group o by o.CustomerID into o where o.Count() > 5 select o.Key).Contains(c.CustomerID)

                   select c;


in 操作

描述:查询指定城市中的客户

查询句法:

        var in操作 = from c in ctx.Customers

                    where new string[] { "Brandenburg", "Cowes", "Stavern" }.Contains(c.City)

                    select c;

Join

描述:内连接,没有分类的产品查询不到

查询句法:

var innerjoin = from p in ctx.Products

                        join c in ctx.Categories

                        on p.CategoryID equals c.CategoryID

                        select p.ProductName;


描述:外连接,没有分类的产品也能查询到

查询句法:

var leftjoin = from p in ctx.Products

                       join c in ctx.Categories

                       on p.CategoryID equals c.CategoryID

                       into pro

                       from x in pro.DefaultIfEmpty()

                       select p.ProductName;


posted on 2008-10-21 17:03  入心  阅读(6076)  评论(1编辑  收藏  举报