zoukankan      html  css  js  c++  java
  • Linq to SQL 语法查询....子查询 & in操作 & join

    子查询

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

    查询句法:

    var 子查询 = from c in ctx.Customers

                       where

                           (from o in ctx.Orders group o byo.CustomerID into o where o.Count() > 5 selecto.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;


    总结得不错,学习了,转载于:http://www.cnblogs.com/cryloo/archive/2008/10/21/1316087.html

  • 相关阅读:
    Python编程知识
    Ubuntu 20.04.3 LTS + Intel Realsense 400系列
    Kubectl
    在Debian Buster中安装redis-cli
    MySQL中最近执行的查询的信息
    EntityFramework 在脚本中使用in
    CLDR TimeZone Mapper
    Skyspark Axon
    Async Restsharp call
    HTTP 1.1 中的Accept-Language header
  • 原文地址:https://www.cnblogs.com/zqonline/p/2004830.html
Copyright © 2011-2022 走看看