-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
EF.CompileQuery parameters #20606
Comments
@smitpatel Why do we only have API for up to five parameters? |
Notes from team discussion:
|
Hi @ajcvickers @smitpatel , Could you please provide any documentation of EF.CompileQuery examples if any? Many Thanks. |
@dotnet/efcore - Can someone explain? An example of API? |
Part of #20606 Upto 15 parameters are allowed. We cannot go further than that. Our return type is Func<> which does not allow more than 16 in parameters. One fixed parameter is TContext. Due to same limitation, the CompileAsyncQuery which also takes cancellationToken can support only upto 14 other parameters.
public static Func<TContext, <#= paramsList #>object[], IEnumerable<TResult>> CompileQuery<TContext, <#= paramsList #>TResult, TProperty>(
[NotNull] Expression<Func<TContext, <#= paramsList #>object[], IIncludableQueryable<TResult, TProperty>>> queryExpression)
where TContext : DbContext |
Without true funcletizer it does not work in current implementation. var query = EF.CompileQuery((MyContext context, object[] parameters)
=> context.Blogs.Where(b => b.Id == (int)parameters[0]));
query(db, new object[] { 1 }).ToList(); |
Part of #20606 Upto 15 parameters are allowed. We cannot go further than that. Our return type is Func<> which does not allow more than 16 in parameters. One fixed parameter is TContext. Due to same limitation, the CompileAsyncQuery which also takes cancellationToken can support only upto 14 other parameters.
Woah! I can see there is a pull request for 15 parameters. When can we expect this to be published @smitpatel , thanks. :) |
Resolves #20606 Upto 15 parameters are allowed. We cannot go further than that. Our return type is Func<> which does not allow more than 16 in parameters. One fixed parameter is TContext. Due to same limitation, the CompileAsyncQuery which also takes cancellationToken can support only upto 14 other parameters.
Hi @ajcvickers , @smitpatel . is this feature going to be released in any of the EF core 3.1.x versions? This is something we are looking for in our project. Many thanks. |
@shivakumarb1989 3.1.x only contain critical bug fixes. All implemented featured will be released in 5.0.0 |
Ok cool. Thanks for the update @AndriySvyryd |
Hi All, One last question. Could we combine multiple EF.CompileQueries? to achieve more parameters. Or is there a work around for this in 3.1.x? many thanks. |
Work-around would involve adding additional method in the own code. The implementation of method uses https://github.com/dotnet/efcore/blob/release/3.1/src/EFCore/Query/Internal/CompiledQuery.cs class, just derive from it, add Execute method with number of parameters you need and use that in implementation. CompiledQuery.cs is in Internal namespace so it can break between releases. But it should work for release/3.1. From 5.0 you wouldn't need a work-around. |
Great. Many thanks @smitpatel . Will try that. |
Currrently EF.CompileQuery supports 5 parameters for querying.
Having said this the EF does not support client evaluation, passing a class as a parameter to EF.CompileQuery throws (limitation / client evaluation) a bug.
I would like to understand if i can achieve atleast 12 parameters(by overloading/extending) the EF.CompileQuery for querying.
Is there any way that we can support more parameters. Or are their any work arounds to acheive this feature.
In future releases are you guys planning to support more parameters? Please let me know your thoughts.
Thanks a lot.
The text was updated successfully, but these errors were encountered: