Sql – Mitigating double mapping model overhead

linq-to-sqlnetpocovb.net

After too much thought, I've decided to use Linq To SQL as a DAL for my project, but keep the business objects as POCO objects.

This will give some flexibility because the database schema is old and have some problems that can not be solved, because backward compatibility.

I'm thinking about making some methods to retrieve or complete the LINQ objects into the POCO objects using Reflection. This methods must try to fill all the properties with the same names.

The question:
Do you know a better way to do the mapping?

Clarifications:
1. I don't want to use NHibernate, Entities, etc.
2. I know that reflection is slow

Best Answer

You may want to look into something like Jimmy Bogard's AutoMapper, which does pretty much what you're talking about. He has it loaded up on CodePlex and GoogleCode, if you want to take a look at it.

Related Topic