-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
No property or field 'DynamicFunctions' exists in type #483
Comments
Sorry I didn't see the issue #396 , but I'm still confused that how to implement 'Like' function in dynamic linq way on EFCore 3.0 or newer? I don't want to use Contains or StartWith.. |
@jacobSpitzer Actually I didn't find a solution using in server evaluation, so I finally switched to Explicit client evaluation. [DynamicLinqType]
public static class KouDynamicFunctions
{
public static bool Like(string fieldContent, string inputPattern) => DynamicFunctions.Like(fieldContent, inputPattern);
} And the dynamic string you can write like this: list.Where("{nameof(KouDynamicFunctions)}.{nameof(KouDynamicFunctions.Like)}({fieldName}, @{num})"); |
maybe you can't use dynamic linq in list...? Sorry I forgot... I first change the dynamic expression into predicate, and then the list use the generated predicate. public static Predicate<T> GeneratePredicateGeneric<T>(string fieldExpressions, object[] fieldValues)
{
return ((Func<T, bool>)DynamicExpressionParser
.ParseLambda(typeof(T), typeof(bool), fieldExpressions, fieldValues).Compile()).Invoke;
} |
how to solve system.Linq.Dynamic.Expection'No proerty or fields'ideas' exist in type 'Customer' |
I want to use Like function in Where clause in dynamic way, and I have included the NuGet Microsoft.EntityFrameworkCore.DynamicLinq, System.Linq.Dynamic.Core, and EFCore 3.1
I simply test it like:
But I only got the exception Unhandled exception. No property or field 'DynamicFunctions' exists in type 'UserBlacklist' (at index 0)
I have tried to replace DynamicFunctions with DbFunctionsExtensions or others, but got the same Exception No property or field.
I even write a member in to dbModel:
but it give me the another exception: could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync().
I also have scrutinized the issue #105 and tried as much as I could but in vain
maybe it's my fault to use it in wrong way? Hope someone could tell me how to use it correctly! Thanks a lot!
The text was updated successfully, but these errors were encountered: