I'm sorry I forgot to mention I'm using AR RC3 (the app has to be running on top of .NET 2.0)
On Aug 11, 12:54 pm, Markus Zywitza <[email protected]> wrote: > ActiveRecordMediator<Customer>.Evict(cn); > > 2009/8/11 Thi <[email protected]> > > > > > I've got an ASP.NET website setup using Castle ActiveRecord and > > Validator, the website is using a custom Http Module to create/dispose > > the SessionScope per request. > > > Scenario: A request comes in to Modify a customer object. > > > Customer cm = Customer.Find(customerId); > > cm.Mobile = newMobileValue; > > > ValidatorRunner _runner = new ValidatorRunner(new > > CachedValidationRegistry()); > > > if (_runner.IsValid(cm)) > > { > > // Update the object, ie: cm.Save(); > > } > > else > > { > > // Handle the failed validators > > } > > > Now regardless if the object failed or not the validation it will be > > saved because the object is dirty, so I thought I could make the > > "global" sessionscope read-only, but that would also be troublesome > > because if I flushed the session it would end up saving all dirty > > objects in it's scope to the database. > > > That lead me to believe I had only one option left, create a read-only > > SessionScope per object I needed to modify it, so flushing it would > > only save what's contained within it, but that has another downside, > > if I'm editing/validating several objects at once creating so many > > sessions would force plenty of database accesses instead of a single > > with only the "valid" changes. > > > So after reading through ActiveRecord's documentation all over again, > > I found somewhere it mentions I could use scope.Evict() to remove the > > object from the SessionScope and bind it again by using object.Save(), > > that sounds like a better approach but I can't find the method Evict > > within my SessionScope, but that would also probably cause me trouble > > with lazily initialized collections. > > > Is there any way I could for example check every object I wanted to be > > updated by calling .Save() and when the session flushed it would only > > persist the changes to the objects I marked instead of them all? > > > So after this essay, would anyone kindly point me in the right > > direction or tell me what/where to read more into how I should be > > handling this? Or any other better way to handle dirty objects versus > > validators, etc. > > > Thanks in advance, > > Thi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
