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 guys,
Here's a sample data model: Book { Id, Name, CreatedOn, UpdatedOn, DeletedOn, LockVersion } Author { Id, Name, CreatedOn, UpdatedOn, DeletedOn, LockVersion } BookAuthor { Id, BookId, AuthorId CreatedOn, UpdatedOn, DeletedOn, LockVersion }
When trying to build a query to locate all books written by a particular author using Entity.Attribute("BookAuthors.AuthorId") == authorId, I noticed the Deleted books showed up in the query result. I only want non-deleted records.
Did I missed something here?
Cheers
Joseph |
|
|
Hi Joe, Nothing you are missing, but something doesnt sound right :) What does the SQL which that is being generated for that query look like? You should see a Books.DeletedOn is NULL criteria as part of the query which will be excluding any soft deleted books.
Jeremy |
|
|
Sorry, I forgot mentioning this: The DeletedOn missing from the query was BookAuthors.DeletedOn So it end up finding books where author has no active (i.e. not deleted) association with.
(I'll put together a sample shortly...) |
|
|
I just re-read my original question... Doesn't sound right indeed... The problem is with BookAuthors, not Books...
*SIGHS* the by-product of working at 2:30AM... |
|
|
I'm using UnitOfWork.Find<Book>(query) And query are constructed in the following two fashion, one produced incorrect result and one doesn't. However, the one producing incorrect result is how I expect to build the query as the association in question in BookAuthors has already been soft-deleted.
INCORRECT RESULT: Entity.Attribute("BookAuthors.AuthorId") == authorId SELECT
CORRECT RESULT: Entity.Attribute("BookAuthors.AuthorId") == authorId && Entity.Attribute("BookAuthors.DeletedOn") == null SELECT
|
|
|
Hi Joe, Yes - this is a limitation around traversals, however its about time we improved that so Ive put in an update for the next nightly to include the SoftDelete on traversals as needed. Believe this should cover what you are looking for :)
Jeremy |
|
|
That's really great! Thanks! :) |
|