How to pass null to int column in linq
How to assign null to int column in LINQ. eg.
SQLDBDataContext sqlD = new SQLDBDataContext();
var result = from p in sqlD.loadsRadius(Convert.ToInt32(Request["radius"]), .....
here, if Request ["radius"] is null, throws an error.
I could go through 0, but I need to change in many of the already existing routines.
Thanks in advance. Anil
+1
anil
source
to share
5 answers
Can you use ?? operator :
Convert.ToInt32(Request["radius"] ?? "0")
If Request ["radius"] is null, it will return "0" instead.
0
source to share