[3.0/LINQ] LINQ with Store Procedure with a Null Paramter
Hi There,
I want to send a null value to the store procedure in C#, but I just can't get that to work, anybody have some idea.
The field type is Guid, so I used the following code.
Code:
DataContext.StoreProc null - Gave me error.
DataContext.StoreProc SqlGuid.Null.Value - Gave me error.
DataContext.StoreProc SqlGuid.Parse("").Value - Gave me error
DataContext.StoreProc SqlGuid.Parse(null).Value - Gave me error
So how do I send a null to a store proceudre?
Any idea?
Regards
PlayKid
Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter
Could you try passing System.DBNull?
Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter
Nop...still give an error, something like unable to convert System.DBNull to System.Guid.
Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter
Try
Code:
Dim sp As New sqlParameter("@Something", dbNull)
Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter
Doesn't like that neither, same error as above, unable to convert SQLParameter to SQLGuid.
But I have decided to use normal ADO.Net instead of going thru LINQ, although I know LINQ is based on ADO.Net, but that null thing just not work for me on LINQ.
Thanks anyway.
Re: [3.0/LINQ] LINQ with Store Procedure with a Null Paramter
Do you have access to the DataContext class itself? You should be able to change the parameters to nullable types, surely...