Is it possible to assign datatype to members of anonymous type in linq query?
2 answers
Not sure if this will work without trying, but you could do this:
select new
{
(int?)lf.id,
}
To force the casting?
Edit: looks like no, but I was able to do this:
List<int> il = new List<int>(){1,2,3};
var z = from i in il.AsQueryable<int>()
select new
{
Foo = (int?)i
};
And it worked fine.
+5
a source to share