asp.net mvc - LINQ, Repository Pattern and Database Abstraction -


I have spent some time resolving a problem for which I have no solution yet. I have a predefined huge database, which is fixed, I use a repository pattern to create an abstract layer between the service code and the database argument. The problem is that I have to apply a processing before moving the database object out of the repository before proceeding. Thus I can not use Linq Entities directly.

Actually, a repository method looks like this:

  Public IList & lt; Bookingcode & gt; FindBookingcode (int id) {return (select where b.ID == id b _db.BOOKINGCODE new Bookingcode {id = b.ID, Name = b.NAME.Trim ()}) ToList () .; }  

This works fine so far. But I have a lot of objects that should be made individually. I FindBookingcode () should return almost all the items, such as catalogs and so on. My problem now is that I would have to re-type the mapping several times like this example:

  Public IList & lt; Bookingcode & gt; FindBookingcode (int id) {return (b equals c1.ID joining c1 in _db.CATALOG b.CATALOGID in _db.BOOKINGCODE where the b.ID == id refs = (from BC1 _db.BOOKINGCODE _db joined the AP. bc1.ID package p.BOOKINGCODE in _db.BOOKINGCODE on p.PACKAGEREF equal join BC2 bc2.ID bc.CATALOGID on bc2.CATALOGID equal to c join _db.CATALOG there is equals c.ID where bc1.ID == b.ID new PackageInfo {id = p.ID BookingcodeRef = new Bookingcode {id = bc2.ID, catalog = new list {id = c.ID}}} ) New Bookingcode {Selection ID = b.ID, Packag Select eInfo = refs.ToList ()}). To create a list (); } I have some L2O processing which collect returned objects. I do not have a good solution for another thing, it will in a way that the repository should receive what, like FindBookingcode (id, includePackageInfo, includeCatalog). 

So here are the questions:

1) Is this attitude totally stupid?

2) If you simplify remapping, which can guide me to a solution?

3) How to apply DDD criteria mechanism

Do you clinics Using SQL or Entity Framework?

I have assumed that here you are using the outline of the unit as you have cited "LINQ institution" in your question.

You should be able to do this kind of mapping using the structure of the unit navigation properties . You need to add a navigation property to each unit that you want to map in this way. It is as easy as explaining to the visual designer, who specify the map in the related attribute in another unit.

Take a look at a quick starter guide. I recommend watching the whole series because they are very informative.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -