sql server left join 变量或常量,与oracle 加号+类似的
public static List 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 andc.sbbh=@sbbh " +
" where a.gyid=@gyid ";
using (var db = Database.DbService)
{
return db.Query(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("msg"); }