views:

21

answers:

1

How do I select all Ids in any entity query as a List?

Let say I have an entity with 2 properties

(int)Id

(any type)(property)

How do I select all Ids in query as a List?

+4  A: 

Like this:

var IDs = from e in Entities
          select e.Id;
Lazarus
that's working but with placing within parentheses and .ToList();so:var IDs = (from e in Entities select e.Id).ToList();
berotomanya
You are right, as it is in my answer you'd get an IEnumerable<Int> rather than a List<Int> but you should be able to iterate over either as List<T> implements IEnumerable<T>.
Lazarus