开发者

What is the point of ParameterSchema.AllowDBNull in CodeSmith?

开发者 https://www.devze.com 2023-03-01 12:41 出处:网络
I\'m currently trying to use write a simple C# wrapper class for all the stored procedures in a database.For this I\'m using CodeSmith and in particular the SchemaExplorer.

I'm currently trying to use write a simple C# wrapper class for all the stored procedures in a database. For this I'm using CodeSmith and in particular the SchemaExplorer.

While iterating through the parameters for a stored procedu开发者_JS百科re, I noticed the property ParameterSchema.AllowDBNull and wondered what this is for. As far as I am aware, it is not possible to declare a parameter as NOT NULL and therefore NULL is always allowed to be passed to any parameter.

Through testing, it appears that AllowDBNull is always true (or at least, I have not been able to write a procedure that results in false). So, this leads me to ask what is it for?

I've found this post from CodeSmith forums from back in 2003: http://community.codesmithtools.com/Support_Forums/f/3/t/264.aspx

They say they will "fix" this in the next release which makes me think there is something that I am missing or not understanding about this property.

Thanks for looking.


I work for CodeSmith Tools and I have updated the forum post from your question. I consulted with Eric about this issue and we decided that it was by design because you can always pass null into a stored procedure parameter. As part of your question, this is a property that is defined in a base class and allows you to detect on other Schema Objects (E.G., ColumnSchema) if the object is nullable.

The CommandWrapper templates will generate a strongly typed class from an existing stored procedure or function. Have you had a chance to take a look at this?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号