DBML generation and SQL UDF [modified]
-
Using functions from SQL server (2005/2008) in linq and encountering a problem with return values. When generating the dbml, visual studio types the function return as system.nullable... [Function(Name="dbo.ToTime", IsComposable=true)] public System.Nullable<System.DateTime> ToTime([Parameter(Name="String", DbType="NVarChar(MAX)")] string @string) Which in this particular case does not work for me (and manually editing it after generation would be troublesome in my environment). I've tried everything I can think of and have come to the conclusion that visual studio's dbml generator simply types any nullable type as nullable. I hope I am wrong...does anyone have any words of wisdom here? Thanks in advance
modified on Friday, April 2, 2010 12:25 PM
-
Using functions from SQL server (2005/2008) in linq and encountering a problem with return values. When generating the dbml, visual studio types the function return as system.nullable... [Function(Name="dbo.ToTime", IsComposable=true)] public System.Nullable<System.DateTime> ToTime([Parameter(Name="String", DbType="NVarChar(MAX)")] string @string) Which in this particular case does not work for me (and manually editing it after generation would be troublesome in my environment). I've tried everything I can think of and have come to the conclusion that visual studio's dbml generator simply types any nullable type as nullable. I hope I am wrong...does anyone have any words of wisdom here? Thanks in advance
modified on Friday, April 2, 2010 12:25 PM
The database generation is driven solely by the data in the database. If you have a function with parameters and no default value then you end up with nullable parameters every time. If you have fields in your table marked as nullable then your data is nullable. For parameters you can pretty much ignore the whole nullable thing if you always pass a parameter.