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'm trying to figure out the entity states in a collection (EntityCollection< TEntity>) to notify user on the UI about dirty state. It works when an entity in the collection is modified or added, but when I remove the entity from the collection which marks the entity as Deleted, there's no way to check if the collection's item has been removed. I have to remove the item from the collection because collection is bound directly to the UI. So the question is, is there any way that I can find out if there's an Deleted item in the original collection? It'd be like exposing a EntityState property but for the collection, or exposing the original items. I think the effort for exposing the original items would be minimal because there is an existing _backup field which contains the removed item. Also returning deleted items from FindAll method would work fine for me.
|
|
|
We're open to doing something like this, but we'd like to understand more clearly what you're trying to achieve here, as it may be possible to do it using existing APIs. Could you give us a bit more info on what you're wanting to do with the deleted item information? |
|
|
In fact, I'm not doing anything fancy...I just want to find out if a collection of entities contain any dirty element. If it does, I'll notify the user on the UI about this dirty state and allow the user to save back the changes. Suppose a UI element like a ListBox is bound to a collection of entities where user can change some of the entity's properties or even mark the entity as deleted by removing it from EntityCollection<T>. If the change is merely a midification of property, I can still use the EntityState of the entities in that collection to find out if the collection has dirty elements, but when it comes down to deleted items (removed from the collection) there's no way of finding it out. Please let me know if I can provide more info. |
|
|
Thanks for the extra info. Depending on the scope of your UI, you may be able to just do this at the unit of work level: bool anyItemDirty = unitOfWork.Any(e => e.EntityState != EntityState.Default); That will tell you whether *anything* needs saving. However, if you're looking specifically to identify whether there are outstanding changes to a particular collection (but you want to exclude changes outside that collection), then obviously this won't do the job. In that case we may need to add an additional API -- let us know. |
|
|
Yes, it works fine but not for my scenario. I'm directly binding the EntityCollection to UI where there's no UnitOfWork available. Collection is prefetched in the repository where UnitOfWork is available and send to UI.
|
|
|
Okay, I've added a Deleted property to EntityCollection<T> which will return you the information you need, and this will be in nightly builds dated 3 Mar 2010 and above, available from about 1500 GMT. Sorry that this has taken a while to happen. |
|