MRFerocius
MRFerocius

Reputation: 5629

C# DTO AND LINQ2SQL

This is my first question, be gentle :). Im working on a project with some kind of distributed architecture.Im trying to do the following:

  1. I have a Data Access Layer that uses LINQ2SQL

  2. I have a Service Layer that is a proxy for the Data Access Layer.

  3. I have a Business Layer that calls the Service Layer for Entities.

    The question is how can I transfer those LINQ2SQL entities to my business Layer?

  4. I want to modify those objects on the business layer and make the travel back with the service layer and re-transform them to LINQ2SQL entities to persist the changes in the DataBase.

    Im sorry if Im asking for some imposible, but Im trying to figure out the beest way but I cant get something intelligent myself :)

    Best Regards!

Upvotes: 1

Views: 1256

Answers (2)

Jonathan Parker
Jonathan Parker

Reputation: 6795

It sounds like you need NHibernate or some other more advanced ORM.

Upvotes: 0

user35559
user35559

Reputation: 1048

Sounds to me like you have 2 different context, the BusinessLogic context and the data access domain. You probably need a transformer/context mapper to convert from one onto another and vice versa.

public class ContextMapper { public BusinessLogic.Customer Convert(DataAccess.Customer customer) {

} public DataAccess.Customer Convert(BusinessLogic.Customer customer) {

}

You could also write these as extension methods if you like

}

Upvotes: 3

Related Questions