Friday, May 20, 2005

[Opf3] ICustomPersister: What a strange interface?!

What is ICustomPersister? First: it's an interface. Second: it allows to create complex objects which hold a bunch of persistent objects.

Perhaps you think now: WHAT?

ICustomPersister contains two methods: Load, Persist. An object that implements this interface can manage the load and persist process by itself. When an object implementing this interface is persistet using the ObjectContext:

context.PersistChanges(objectImplementingICustomPersister);

The ObjectContext returns the control to the object. The object can now save it's parts by using the ObjectContext. The same happens while loading the object.

When is something like this useful?
Immagine you have a complex object. For example a list of objects (the ObjectSet<T> implements this interface) or a car object. The car, for example, has two doors and an engine. It holds internally those three objects and knows how to save or load them from the database. When you load the Car object from the storage you have simply to set an instance of the Car object as argument of the GetObject method of the ObjectContext.

Car car = context.GetObject<Car>(new Car(), "Name = {0}", "Bugatti");

The ObjectContext returns the control of the load process to the instance of the Car object. The Car object gets the query and the instance of the ObjectContext that redirected the control. This allows the object to load the parts by itself.

While saving:

context.PersistChanges(car);

the object has also full control over its persisting behaviour. The car object can save first the doors and then the engine or first the engine and then the doors. The ObjectSet<T> saves for example all persistent objects in the main list and deletes all persistent objects that are found in the RemovedList property of the ObjectSet<T>.

14 Comments:

Anonymous Anonymous said...

Hi,

you really have a very nice blog here! I'm definitely going to bookmark you!

I have a site dealing with california seo. You are heartly invited to take some really good tips from it.



Come and check it out if you get time :-)

TheSEO-Rank.com

10/11/2005 11:23 PM  
Blogger Greg said...

This site is great, nice job!!

I have a SEO info site. It is about seo spain articles and stuff.

Drop by when you can, nice site here!

10/18/2005 6:55 AM  
Blogger Greg said...

Hi,

you really have a very nice blog here! I'm definitely going to bookmark you!

I have a site dealing with six powerful ways
. You are heartly invited to take some really good tips from it.



Come and check it out if you get time :-)

TheSEO-Rank.com

10/20/2005 7:44 AM  
Anonymous Anonymous said...

Wow, I really like this one. I have a website that talks mostly about seo consultancy You should check it out sometime.

10/30/2005 10:51 AM  
Anonymous Anonymous said...

nice blog enjoyed it :)

Keep up the excellent work! and i bookmarked u!

so cant wait for ur next post! :)

Thanks!!

11/01/2005 5:22 AM  
Blogger Greg said...

Nice Blog!!! It looks like you have spent a fair amount of time setting it up and keeping the content fresh. Congratulations. I'll be sure to come back later again.

I have a SEO tips site. It pretty much covers google help
related stuff.

Thanks again and keep up the good work.

Greg
theseo-rank.com

11/01/2005 2:20 PM  
Anonymous no fax payday loans said...

how do you come with so many ideas. i am trying to write on my no fax payay loans , but can get much out of it .
hope this helps me out. thanxs

4/10/2006 12:31 PM  
Anonymous Anonymous said...

the good thing about your blog is, its natural. Appreciate your views and added my comment on it. keep it moving and have a great blog. cheers !!!! faxless payday loan

6/23/2006 8:47 AM  
Anonymous Anonymous said...

Leave me your blog address at no fax payday loan and I'll be sure to add
it to my blogroll and come visit you. It's just over there on the right - just click
to add your pin to the map.

6/27/2006 12:09 PM  
Anonymous Anonymous said...

So far, two people have come out and said they think that Day By Day is at leastsometimes funny. Neither has provided any physical evidence of this. so please have a look at Quick payday

7/06/2006 12:28 AM  
Anonymous Anonymous said...

Good afternoon many have machines which not insuranced,
you have a unique opportunity only today to receive insurance the machine free of charge
auto insurance
auto insurance
cars insurance
cars insurance
texas car insurance
texas car insurance
car insurance quotes
car insurance quotes
car insurance policy
car insurance policy
xanax
phentermine
buy tramadol

12/02/2006 12:20 AM  
Anonymous Anonymous said...

Hi people
I do not know what to give for Christmas of the to friends, advise something ....

12/03/2006 3:08 PM  
Anonymous Anonymous said...

Mmm my sweety private weblink collection. I hope you enjoy it !
ass parade
naruto xxx





------------------------------------------------------------------------------------------------
About Christmas
merry christmas

12/09/2006 4:43 PM  
Anonymous Anonymous said...

xanax
phentermine
buy tramadol
big breast
merry christmas
ass parade
naruto xxx
auto insurance
auto insurance
cars insurance
cars insurance
texas car insurance
texas car insurance
car insurance quotes
car insurance quotes
car insurance policy
car insurance policy

12/13/2006 3:21 PM  

Post a Comment

<< Home