Thursday, 5 September 2013

Convert IEnumerable to List of properties

Convert IEnumerable to List of properties

pSay I have a class called Event:/p precodepublic class Event { public
virtual int Id { get; set; } public virtual string Title { get; set; }
public virtual string Description { get; set; } } /code/pre pAnd have the
following query:/p precodevar events = _eventInformationRepository.Fetch(e
=gt; e.Id != -1); /code/pre pWhich returns an
codeIEnumerablelt;Eventgt;/code. But I'd like to create a list of IDs of
events. Can this be done directly via ienum? Or do I have to generate the
list, iterate, assign and add each value?/p

No comments:

Post a Comment