sql server left join 变量或常量,与oracle 加号+类似的

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dacong/article/details/44685945


sql server  left join 变量或常量,与oracle 加号+类似的


 public static List<MesGxzyWlptInfo> GetWlptByGyId(int gyid,string sbbh)
        {
            string sqlstr =
         "select A.ID,A.WLBM,B.LJTH,B.LJMC,A.XQSL,A.GYID,B.TPDZ,ISNULL(C.KCSL,0) KCSL,0 SQSL,isnull(c.id,0) as KCID"+
         " from dbo.MesLjzpgyGxwl a"+
         " inner join dbo.MesLzjjbxx b "+
         "  on a.wlbm=b.ljbm "+
         "    left join dbo.MesSbwlkc c"+
            "  on a.wlbm=c.wlbm and c.sbbh=@sbbh " +
         "  where a.gyid=@gyid ";
            using (var db = Database.DbService)
            {
                return db.Query<MesGxzyWlptInfo>(sqlstr, new { gyid,sbbh}).ToList();
            }
        }

Dapper left join
Dapper 动态参数,Output返回值
 public static string KaiGong(int id,string sbbh)
        {
            var spname = "dbo.[sp_MesGxzy_KaiGong]";
            var args = new DynamicParameters();
            args.Add("gxzyId",id);
            args.Add("sbbh",sbbh);
            args.Add("msg", "OK", direction: ParameterDirection.Output);
            using (var db = Database.DbService)
            {
                db.Execute(spname, args, commandType: CommandType.StoredProcedure);
            }
            return args.Get<string>("msg");
        }

没有更多推荐了,返回首页