This is a weird one that i can't figure out.
My method has one paramemer a nullable int
int? selectedtitleid
This is the Linq code:
var titles = from t in dc.Titles
select new SelectListItem
{
Text = t.Title1,
Value = t.TitleID.ToString(),
Selected = (t.TitleID == selectedtitleid)
};
return titles.ToList(); // Error gets thrown here
It works fine when selectedtitleid is not null - but throws an exception when it is null.
The exception is : The null value cannot be assigned to a member with type System.Boolean which is a non-nullable value type.
I did a test which was something like this
int? t1 = null;
bool b1 = (t1 == null);
And b1 gets set to false - so why doesn't this happen in the Linq query ?
It's probably something simple - so anyone any ideas ?
Cheers