zoukankan      html  css  js  c++  java
  • Linq和EF 做 单一条件查询 和 复合条件 查询 以及 多表 联合查询 示例

    单一条件查询:

    var table2Object = (from t1 in db.table1
                 join t2 in db.table2 on t1.id equals t2.id         
                 select t2).FirstOrDefault();

    复合条件 查询:

    多个主键 联合查询

    var table2Object = (from t1 in db.table1
                 join t2 in db.table2
                 on new { t1.id, t1.another_id } equals new { t2.id, t2.another_id }
                 select t2).FirstOrDefault();

    多表联合查询:

    Join3个Table

    var table2Object = (from t1 in db.table1
                 join t2 in db.table2
                 on new { t1.id, t1.another_id } equals new { t2.id, t2.another_id }
                 join t3 in db.table3
                 on new { t2.id, t2.another_id } equals new { t3.id, t3.another_id }
                 select t2).FirstOrDefault();
  • 相关阅读:
    简单工厂模式
    单例
    开发帮助网址
    图片上传
    数据提交
    存储过程
    标量值函数
    linux查看TCP各连接状态
    nginx配置文件nginx.conf
    php配置文件php-fpm.conf
  • 原文地址:https://www.cnblogs.com/x-poior/p/4914446.html
Copyright © 2011-2022 走看看