Figure out how to do the best Save method for IRpository.Save()


I´ve been thinking a bit about the Save functions for the repositories. I like the design to have the same method for insert and updates.I don´t really know if this is the right way to go but it works for now.I have plans of doing a generic save function but I can´t figure out how to do it best.Take a look in ProductRepository.


Glenngbg wrote Mar 17, 2009 at 7:44 AM

Now I have figured out a pretty neat solution.
I use simple logic (ProductId==0) to see if a product is new or not.
If it´s new I just Add a new product to the EntityModel and saves.
If it´s not new I use a generic method in EntityRepositoryBase to see if a have a corresponding entity in my entitymodel.
I so I just update it, else I attach a new Entity with the the right key.

wrote Feb 13, 2013 at 3:07 AM