与LINQ存储过程prevent参数可为空 [英] Prevent nullable parameter in stored procedure with LINQ

查看:130
本文介绍了与LINQ存储过程prevent参数可为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要定义存储过程的参数,不允许空参数。

I want to define stored procedure parameters which do not allow null arguments.

这是 @MailItemId INT输出,因为当我导入存储过程到LINQ to SQL设计它说@MailIetmid是将不可为空 REF诠释? mailItemId

That @MailItemId int OUTPUT will be not nullable because when I import the stored procedure into the LINQ to SQL designer it says @MailIetmid is ref int? mailItemId.

感谢。

推荐答案

如果没有别的,你可以修改自动生成的code(在designer.cs)不接受空整型。如果该参数不过最终被空,它可能会导致一个奇怪的例外,倒在LINQ到SQL code,但是这不是一个巨大的交易。

If nothing else, you can just modify the auto-generated code (in designer.cs) to not accept a nullable integer. If the parameter ever does end up being null, it will probably cause a weird exception down in the LINQ to SQL code, but that's not a huge deal.

这篇关于与LINQ存储过程prevent参数可为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆