-
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. |
No description provided.