views:

298

answers:

1

I'm considering using LINQ-to-SQL for creating the DAL in my app. I normally create the DAL manually as I'm not a big fan of ORM (too much abstraction IMO) but I'm trying to save some time for an impatient client.

My question is, how do you map the classes generated by LINQ-to-SQL to your BLL classes? Do you just add your code to the classes generated by LINQ-to-SQL (they are partial classes) and don't create BLL classes at all (so the class work as both a DAL and BLL class) or how do you normally do it?

Thanks

+6  A: 

The important distinction is recognizing that LINQ to SQL actually has two parts: the entity classes which you own - they are either generated or hand-written in your solution - and the LINQ to SQL libraries which do the heavy lifting of translating LINQ expressions into SQL and projecting the results. The former is your BLL, and the latter is your DAL. The LINQ to SQL model mostly fulfills this, as the DAL is entity-agnostic (or BLL-agnostic); and your entities have very loose couplings to the DAL; they can be used apart from the DAL entirely if necessary.

So, the short answer is the LINQ to SQL model can fulfill both the DAL and BLL roles, but just because you're using one model for both doesn't mean you're combining the two layers inappropriately.

Rex M
This answered the question. Thanks a lot
Waleed Eissa