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, I have a transient property "CountryOfOrigin" that I populate in AfterLoad(). What is the lifespan of this property? I have an asp .net application but the transient field seems to be lost on postback. Do I need to declare a global unit of work and initiate the object in it's context? Are transient objects lost in different units of work? Thanks sr |
|
|
The lifespan of the transient field is the lifespan of the entity instance. In a postback situation, you materialise the entity anew during each request, and this instance is discarded when the request is discarded. So you get one entity instance when serving the page, and a different entity instance during postback. Any transient or unsaved changes made during the first request will be lost along with that first entity instance; the second entity instance will be freshly reloaded from the database, and will have its own copy of the transient fields. |
|
|
Thanks for the replay Ivan. In the case where 'Cached' is set to 'True' for an Entity, does it still reload the object every time from the DB? Where what is the scope of this cache and where is it being stored? Thanks, sr |
|
|
No, if the entity is cached then it will be reloaded from cache instead of from the database. The scope of the cache depends on the kind of cache you are using. E.g. the default cache is the ASP.NET cache which I think is per-process (not sure), but we also supply a Memcached implementation which can span multiple machines, and you can implement your own using the ICache interface. However, looking at our caching code, it looks like transient fields are not cached, and would still need to be reacquired after an entity is reloaded from cache, just as if it were being reloaded from the database. |
|
|
Thanks, I am playing around with memchaced right now to see how it can help. Can I put in a feature request to cache transient fields also? This would be a great help.. |
|