This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, At the start of a web request I create a unit of work and store it in the HttpContext. At the end of the request I then do a SaveChanges() and Dispose of the unit of work. I am having an issue though when I am doing an Add during a request and then do subsequent Find's that should retrieve the object I added prior in the request. The new object is not showing up. Is this how it is supposed to work or should I be getting back the object that I Added even if I haven't done a SaveChanges() yet? Thanks, Craig |
|
|
No, Find only consults the database (and the same applies to other query methods). One possible way to get around this is to start a transaction when you create the unit of work, then do a SaveChanges immediately after the add, but without committing the transaction at that point. Then subsequent Finds on the UOW should bring back the new entity, but other UOWs won't see the "provisional" object, and you can back out the transaction if you later decide you don't want the entity to persist. |
|