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! Do I have to select an entity before I can delete it if I only have the id of the entity? I have something like this:
} Can I do this without first fetching the entity from the db?
|
|
|
Hi Magnus, We're going to add support for this in the next couple of days. I'll let you know when it's available in a nightly build. Cheers, Andrew. |
|
|
Did you succeed in putting in this functionality and how is it used?
|
|
|
Yes, this has been in for a while now. How to use it: 1. Create a Query representing the entities you want to delete e.g. Query oldAccounts = new Query(typeof(Account), Entity.Attribute("LastActive") <= DateTime.Now.AddYears(-1)); 2. Pass that to IUnitOfWork.Remove(Query) e.g. uow.Remove(oldAccounts); 3. Call IUnitOfWork.SaveChanges(). Note that the deletion does not happen until you call SaveChanges. Also note that this completely bypasses the entity map: entities in memory or in the cache will NOT have their status updated to reflect the fact that they are marked for deletion. So generally avoid mixing delete-by-query with "normal" entity operations, or at least take care! |
|