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
|
Is there a difference between calling a setter method on an attribute and using UnitOfWork.Update? Do I always have to search for an existing item using a query on a UnitOfWork to add it to the current UnitOfWork? Is it better to use the Entity's Id wherever you don't need the object?(are there any problems with this approach) Thanks, Edward
|
|
|
[quote user="edward"]Is there a difference between calling a setter method on an attribute and using UnitOfWork.Update?[/quote] Yes. Calling a setter method updates an in-memory entity: if you call the property getter after calling the setter, you will see the change applied. UnitOfWork.Update builds a SQL statement to be sent to the database during SaveChanges(). It completely bypasses the in-memory entity, the identity map and the L2 cache. [quote user="edward"]Do I always have to search for an existing item using a query on a UnitOfWork to add it to the current UnitOfWork?[/quote] You can use the Attach method to move entities between units of work, but this is an advanced technique. In normal circumstances yes, you must use a query (though note that you can use the FindById() method which is extremely efficient). [quote user="edward"]Is it better to use the Entity's Id wherever you don't need the object?(are there any problems with this approach)[/quote] It's more efficient if you're not going to need the object, and there shouldn't be any problems with it. |
|