您好,登录后才能下订单哦!
问题描述:
MVC5项目,利用执行sql的方式获取数据,但是在利用预编译执行的时候报错了,字段XXXwhich was not supplied.
其实就是这个参数传了个null导致的。在传参数之前做个判断,如果为null就赋值为空串即可。
(=
String sql = "select a.Id,a.UserName,a.TrueName,ISNULL(b.OTM, '0') as Flag from SysUser a left join FIX_MatchingModel b on cast(a.Id as varchar) = b.OTM and b.Id = @matchingId Where a.DepId = @DepId order by b.OTM desc";
SqlParameter[] sqlParameters = { new SqlParameter { ParameterName = "matchingId", Value = matchingId }, new SqlParameter { ParameterName = "DepId", Value = depId } };
DbContexts DbContext = new DbContexts();
return DbContext.Database.SqlQuery<UserView>(sql, sqlParameters).ToList();
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。