-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
POC of Mql.Field (could be used by EF Core Provider to support shadow properties). #1373
base: main
Are you sure you want to change the base?
Conversation
var collection = GetCollection<C>(); | ||
|
||
var queryable = collection.AsQueryable() | ||
.Select(root => Mql.Field(root, "X", Int32Serializer.Instance) + 1); // like root.X except C does not have a property called X |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to know the container, even if it is only the root
.
X
is like a shadow property. It exists in the document in the database but not in the class C
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the overall technique. If we are going to productionize it, we probably would want to make the serializer optional, which poses some challenges. root => Mql.Field<int>(root, "X") + 1
feels more natural, but C# doesn't allow partial generic type inferencing.
I can see where specifying the serializer makes sense for advanced use cases, but in common cases such as strings, integers, bools, etc., it will be more useable to specify the field type.
The serializer is important because it defines how the field is represented in the database. If it is not provided, where would we get it from? The only reasonable place would be the |
Tested and working well with the EF Shadow Properties implementation and also for select projection rewriting. |
Two open questions here:
{ "$match": {
"$and": [
{ "$expr" : { "$eq" : ["$planetId", { "$oid" : "621ff30d2a3e781873fcb663" }] } },
{ "$expr" : { "$eq" : ["$label", "VI"] } }
]
},
{ "$limit" : 1 } But when executing against the same properties as CLR properties I get a quite different query: { "$match" :
{ "_id.planetId" : { "$oid" : "621ff30d2a3e781873fcb663" },
{ "_id.label" : "VI" }
},
{ "$limit" : 1 } Why are the ones from MqlFied using $expr and why do they get wrapped in an additional $and ? |
Because initially I only implemented The |
It's a bit arbitrary when we use "field" and when we use "element". I don't think the server team ever uses the term "element". To them it's always a "field". |
Not sure about paths... I was envisioning that |
Looking at this in more detail I believe that
The server expects you to nest calls to |
I've pushed a new commit adding support for Mql.Field in filters. |
POC working great here now as the backing for EF-42 (shadow properties). |
No description provided.