I have an object model like this:
public class MyObject{
public int Prop1{get;set;}
public int Prop2{get;set;}
}
I use this object in a
Why not use Nullable then?
public class MyObject{
public int? Prop1{get;set;}
public int? Prop2{get;set;}
}
int? is a shorthand of Nullable. That means, now Prop1 and Prop2 both can be null.
Or if you want zero, instead of null, then do this in the LINQ :
select new MyObject() { Prop1 = p1 ?? 0, Prop2 = p2 ?? 0 }