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 there, I've noticed that the results returned from the following two linq expressions in which I've changed the order of the join/from expressions give different results. The difference is that the first query does not contain any deleted questions even though IncludeDeleted() is used:
Using Linqpad and the lightspeed driver, the generated SQL is: (query1)
(query2)
It seems that the IncludeDeleted() method isn't working when used in a Join expression (notice the ".DeletedOn IS NULL" statements are still present). Is this a bug, or do I need to perform my queries in a different way? This is using the latest nightly build (Version: 4.0.1466.20917) Thanks, Paul |
|
|
Hi Paul, IncludeDeleted() is a query level setting which applies to the entity being queried on and not entities which are joined so only the IncludeDeleted() attached to the primary entity in the query is being applied. In query 1 this is BoardParticipants:
In query 2 this is Questions
|
|
|
Hi Jeremy, Thanks for your reply. Are you able to suggest a workaround to achieve the intent of my queries? Thanks, Paul |
|
|
Hi Paul, Are you able to look at using a stored proc for this? Because we are going to always include the soft delete attribute for joined entities this means you are going to have limited control over this through using the Querying API or LINQ. We are having a think about changing the behavior of this to respect that flag for joined entities but we wont be making this change in 4.0.
|
|
|
Hi Jeremy, Currently I'm working around this by simplifying all of our queries and performing all of the join logic in memory. At this stage performance isn't an issue so hopefully that's all I'll need to do. Is there a case for throwing an exception or something in the situation where IncludeDeleted() has been used but is silently being ignored. In my particular case, my misuse of IncludeDeleted() lead to a bug that went unnoticed in our system for quite a long time. Anyhow, my current workaround is acceptable, if performance becomes a problem I'll consider stored procedures. Thanks for you responses, Paul |
|
|
Hi Jeremy, Has there been any update on this? Using IncludeDeleted in Joins? Thanks - Imtiaz |
|
|
No there has been no change with this.
|
|
|
Is there a known work around yet? I just wasted a day on this too. I would agree that methods that silently fail are a bad idea. I'd rather not do the join in memory as that was exactly what I was in the process of removing when I hit this issue. |
|
|
No there isn't any change to this but this is a good reminder we should look at throwing an exception if IncludeDeleted is specified on a joined entity in the query so I will have a look into that.
|
|