views:

16

answers:

0

DAL library exposes interfaces that return and accept application domain POCO classes. DAL uses EF inside with EDMX generated classes. What are the best practices to convert POCO to EDMX?

It may be straightforward

public PersonInfo GetById(Guid id)
{
   return DataContext.PERS.FirstOrDefault(x => 
     new PersonInfo { Id = x.Pers_id, Name = x.Name, **+10 more fields** };
}

And another example:

public void AddPerson(PersonInfo person)
{
   PERS p = new PERS { Pers_id = person.Id, Name = person.Name, **+10 more fields** };
   ...
}

There are tons of code that convert POCO to EF and vise versa. Nowadays I put the most of that to private static DAL Helper classes with static methods that implements such conversions.

How do you usually perform that operations? May be I should not concern much about how and where to convert or may be it's better to map database fields appropriate to POCO fields via reflection?

Thank you in advance!