Object / Entity mapping

Posts   
 
    
Azag
User
Posts: 2
Joined: 27-Oct-2010
# Posted on: 27-Oct-2010 04:25:21   

Hi All,

We have a number of custom classes that contain custom logic - each of these essentially map to a database (read:llblgen) entity. The custom logic class is essentially a super set of the llblgen entity class - however we cannot have a direct dependency upon it.

What we wish to do is to use the custom classes within the system and use the llblgen entity as our persistence layer.

We currently have a structure like this (hand written pseudo code)

public class Book : IDBPersist { public string BookName;

....

public void Persist() { MapObjectToEntity(); Entity.Save(); }

public Load() { Entity.Find(); MapEntityToObject(); } }

I am wondering whether there is a better/more preferred method to do something like this.

Thanks, Rob

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 27-Oct-2010 09:28:18   

This is a valid approach.

But may I ask, why don't you use LLBLGen entities through out your system, and then you can implement the custom logic in separate files (partial class file)?

Azag
User
Posts: 2
Joined: 27-Oct-2010
# Posted on: 01-Nov-2010 00:10:12   

Walaa wrote:

This is a valid approach.

But may I ask, why don't you use LLBLGen entities through out your system, and then you can implement the custom logic in separate files (partial class file)?

I guess our issue with using partial classes is that we wish to decouple the "persistant" view of the object from the "real" view of the object - so wanted to keep the 2 classes separate. So if I have an application that doesnt use a DB at all (perhaps it persists via Xml files or something) - I dont want to have to give it an understanding of the llblgen layer.