views:

67

answers:

0

I currently have a custom ORM. I have a business layer, and data layer.

My Data layer has all my CRUD operations. In the example below, I pass an Id to the constructor. This gets the record from the DB and fills the object with my person record:

E.g.

//Access through business layer
Dim person as new Business.Person(Id:=1)
person.Data.Forename = "jamie"
person.Data.Save()

I can change the record and call Save(). I can also call Delete().

If I want to insert a record, I will create an instance of Person without passing in an Id, set the properties, then call Save(). Save will check if the Id is set. If so, Insert() else, Update().

I know EF4 creates partial classes, and you makes changes against a database context rather than an single entity. I wonder if anyone could give me an example of a similar implementation of what I already have using EF4.