zoukankan      html  css  js  c++  java
  • EF使用sql语句

    https://www.cnblogs.com/chenwolong/p/SqlQuery.html

    https://blog.csdn.net/zdhlwt2008/article/details/77832858

    public static IQueryable<DAL.ZTHR.ZTHROrgUnit> QueryCTESub(string id, Chaolj.DAL.ZTHR.ZTHRContext db)
            {
                IQueryable<DAL.ZTHR.ZTHROrgUnit> qry = null;
    
                // 1. 先根据Id 查询出编码;
                var model = Get(id);
                if (model == null) return null;
                string no = Get(id).No;
                // 2. 再根据No构建sql语句
    
                string cteSql = @"WITH org(""Id"",""No"",""Name"",""ParentNo"",""LeaderId"",""Leader"",""Comment"",""Sort"",""OrgTypeNo"",""OrgType"",""CreateUser"",""CreateTime"",""UpdateUser"",""UpdateTime"") AS "
                                + "(select "
                                + @"""Id"",""No"",""Name"",""ParentNo"",""LeaderId"",""Leader"",""Comment"",""Sort"",""OrgTypeNo"",""OrgType"",""CreateUser"",""CreateTime"",""UpdateUser"",""UpdateTime"" FROM ""ZTHROrgUnit"" WHERE ""No""='" + no + "' "
                                + @"UNION ALL "
                                + @"SELECT z.""Id"",z.""No"",z.""Name"",z.""ParentNo"",z.""LeaderId"",z.""Leader"",z.""Comment"",z.""Sort"",z.""OrgTypeNo"",z.""OrgType"",z.""CreateUser"",z.""CreateTime"",z.""UpdateUser"",z.""UpdateTime"" FROM ""ZTHROrgUnit"" z "
                                + @"INNER JOIN org o ON z.""ParentNo"" = o.""No"")"
                                + @"SELECT * FROM org ORDER BY ""ParentNo""";
                qry = db.ZTHROrgUnit.SqlQuery(cteSql).AsQueryable(); // .ToList();
    
                return qry;
            }
  • 相关阅读:
    VUE的生命周期
    ID生成算法(二)
    ID生成算法(一)——雪花算法
    HTTP状态码和支持的方法
    水平居中/垂直居中/水平垂直居中总结
    判断数组类型的4种方法
    WebSocket浅谈
    vue中使用定时器时this指向
    银行转账业务梳理
    支付那些事儿
  • 原文地址:https://www.cnblogs.com/hwubin5/p/10365485.html
Copyright © 2011-2022 走看看