Last post Dec 20, 2007 02:43 PM by jf26028
Dec 19, 2007 11:57 PM|jf26028|LINK
I am trying to get my linq hat on right, and hopefully, someone will have some insight on how to do this.
I would like to build a data access layer for my website. These are my requirements:
1. Use the Linq To Sql entities for all the model.
2. Support both sql server and xml as the data source via a providered interface.
Think .nettiers or blogengine, but using linq to sql for the sql provider, linq to xml for the xml provider, all the while having the entities generated from the dbml file, or sqlmetal. The thing I am having a hard time with is removing the entities generated
by the dbml file from the data access to enable returning the entities from both, the sql and xml providers. I dont think that this approach is possible with linq, but I really hate to give up on it so quickly. Anyone have any suggestions, other than something
like DTOs and converting from the sql entities into some common object and having to support 3 versions of the entities in a single project?
Jesse Foster | jf26028
Dec 20, 2007 01:10 AM|marcind|LINK
this forum is mostly for the ASP.NET 3.5 Extensions Preview. For LINQ-related questions, pleas visit
Dec 20, 2007 01:25 AM|marcind|LINK
Sorry, I misread your question. The Linq to SQL and Linq to XML models are different (what they share in common is the LINQ part - programming language syntax for performing queries on the data) and there is no common abstraction layer on top of them.
Dec 20, 2007 12:19 PM|jf26028|LINK
You are right, marcind. This post should be moved. Can someone move it for me?
Anyway, the closest I have some is using a raw set of model classes, and in your linq to sql entities, you have to do something like this:
Then, you do the same over in xml land, and it should work. You still have a dto type situation with the same model defined in Monkey.Northwind as in NorthwindTest.Data, but there is no way to get around it, from what I can tell. So, you
can have a clean model with providers for both xml and sql server using linq as your data access, without violating DRY too much.
Inserts and updates, like with all of linq, are another story and Ill check those out next.
Dec 20, 2007 02:43 PM|jf26028|LINK
It looks like other people have started doing the same types of things: