-
Notifications
You must be signed in to change notification settings - Fork 836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linq to DocumentDb, where clause on child #58
Comments
Could you please do a .ToString() on the wrong & correct before calling ToArray(). var correct = _client.CreateDocumentQuery<Resource>(_collection.DocumentsLink) and var wrong = _client.CreateDocumentQuery<Resource>(_collection.DocumentsLink) I suspect you will find that "wrong" is not doing the x.IsDeleted check server-side, but client-side. will need to look in to why the "wrong" doesn't populate the fields of the returned objects though, it should. are you able to share some sample documents (even if you email or share with ryan craw at microsoft dot com) |
@ryancrawcour Thank you for your response.
I don't want to sound cocky, but i disagree to the last part of your statement. Imho, if you expose an Below is the result of doing a ToString() on each of the queryables:
This looks promising! The actual queries are almost the same and everything is done on the server. For context, below is the type definition of public class DocumentType : AggregateRoot
{
public string Name { get; set; }
public bool IsDeleted { get; set; }
}
public abstract class AggregateRoot
{
public string ResourceId { get; set; }
public bool IsTransient()
{
return string.IsNullOrEmpty(ResourceId);
}
} Also, per your request, assume these sample documents:
Hope this helps. Any idea when the actual source of the linq provider will be accessible on github? |
So there's a subtle difference between the two queries which I need to investigate. The one is selecting only Model, where the other is selecting *. |
fixed in v.1.5.1 |
@ryancrawcour I'm sorry, but the latest release did not entirely fix our problem. Please assume issue #81 as entered by my colleague @mmsommer. |
In a project i'm currently working on, we have come to realise that we should not use DocumentDb collections as if they are the equivalent of a table in f.ex SQL Server. As a result, we are now persisting all of the entities, belonging to a single tenant in a single collection.
We already have lots of linq queries in our codebase which assume that each document type (aggregate root) is persisted in a dedicated collection. In an attempt to make the transition painless, i set out to refactor our data access object, so that its api continues to reason about aggregate roots, and deal with the single collection vs dedicated collections in it's implementation.
My approach is to wrap an aggregate root in an
Resource<T>
object, which derives fromResource
and exposes aModel
property as well as aType
property. I thought i would then be able to expose anIQueryable<T>
to consuming code based on the following code:Initial testing showed that this worked as planned and i confidently committed my changes. When doing functional testing however, we found that some queried models had all of their properties set to their default values (ie. null, 0, false, etc).
I can reproduce the problem with the following code:
The results of the above queries are not the same!!
TModel
instances.In order for my refactoring to be successful, i need
wrong
to be ... right :) Falling back to SQL is not an option as we value type safety of linq. Changing our approach to expose theResource<T>
objects would touch lots of code, as it requires all*.Property
references to be substituted by*.Model.Property
references.It seems an issue with the linq provider that is part of the DocumentDb client.
We use Microsoft.Azure.DocumentDb version 1.4.1
The text was updated successfully, but these errors were encountered: