select ID, 0 as Index from Table;
How do I do this query in linq?
var o = From X in Table Select X.ID, (0 as Index) <- error
select ID, 0 as Index from Table;
How do I do this query in linq?
var o = From X in Table Select X.ID, (0 as Index) <- error
var o = from x in Table select new { ID = X.ID, Index = 0 };
The new
keyword here creates a new anonymous type that gets exposed by the query. The first property, ID
, is populated by the ID
property from X
. The second property, Index
, is given the static value of 0
.