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
|
i have a prices table that stores prices etc for a given item. For the Price entity, i also have some Transient properties and an "AfterLoad" method which populates these extra properties (margin and markup calculations). when i come to update the database, i check to see the entity state for each price item - if it is new / modified / deleted, i then update the database with the updated values. but the entitystate on the price items gets set to modified because of the transient properties / Afterload method - so i am un-necessarily updating the database (and writing an extra Audit record) is there a way around this (eg. something like "reseting" the entitystate as the end of the afterload method) - so that i can still tell if the user has updated the record as opposed to the transient properties / afterload method changing it
|
|
|
Hi Mark, Can you give a quick example of how you are declaring your Transient properties? The Transient attribute which should be being applied to a field, indicates to LightSpeed that it should be ignoring this field, so it should not be being factored in part of the EntityState. One thing to make sure of is that you are not declaring the property settor in a similar way to standard properties on the entity. e.g. This would be incorrect: [Transient] Instead you should just use direct assignment to the field like: public string Foo Lastly, you should not need to be referring to the EntityState within your code - LightSpeed uses the EntityState to determine if an entity should be added/removed or updates as part of a unit of work. You only need to determine if you want to commit the changes and then call UnitOfWork.SaveChanges(); This will throw a ValidationException if any of your entities are in an invalid state.
Hope that helps, Jeremy |
|