How to convert an EntityCollection<T> to List<POCOObj>

Posted by ggomez on Stack Overflow See other posts from Stack Overflow or by ggomez
Published on 2010-03-13T07:44:43Z Indexed on 2010/03/13 7:55 UTC
Read the original article Hit count: 362

I have Entity Framework entities Events which have an EntityCollection of RSVP. I want to convert the EntityCollection of RSVP to a generic List<> of a POCO class RSVP.

So I want EntityCollection -> List.

What would be the best way to go about achieving this?

So far I have this (it's missing the RSVP part)

var events = from e in _entities.Event.Include("RSVP")
                     select new BizObjects.Event
                     {
                         EventId = e.EventId,
                         Name = e.Name,
                         Location = e.Location,
                         Organizer = e.Organizer,
                         StartDate = e.StartDate,
                         EndDate = e.EndDate,
                         Description = e.Description,
                         CreatedBy = e.CreatedBy,
                         CreatedOn = e.CreatedOn,
                         ModifiedBy = e.ModifiedBy,
                         ModifiedOn = e.ModifiedOn,
                         RSVPs = ???
                     };

Thanks.

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about c#