tags:

views:

19

answers:

1

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

+3  A: 
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.

Adam Robinson