zzzprojects / Eval-Expression.NET

C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
https://eval-expression.net/
Other
459 stars 86 forks source link

Seems doesn't support EF.Functions?? #102

Closed noezad closed 3 years ago

noezad commented 3 years ago

The following statement will report an error.

var allEvent = await (from n in _context.Events .WhereDynamic(c => "EF.Functions.Contains(c.UseInSearch, search) && c.IsDelete == false") ...

The error is as follows

EvalException: Oops! No applicable member has been found for the expression. Tnx

JonathanMagnan commented 3 years ago

Hello @noezad ,

Could you provide your EF version including the EF provider package you are using,

My developer did a test and it's worked on his side, so perhaps that's a package we didn't include yet.

Best Regards,

Jon

JonathanMagnan commented 3 years ago

Hello @noezad ,

Since our last conversation, we haven't heard from you!

Don't hesitate to provide your EF version and the EF provider package you are using, so we can assist you better!

Looking forward to hearing from you,

Jon

noezad commented 3 years ago

Hi Jon,tnx for your massage I am using Ef 3.1 and Sql Server Have a good time

JonathanMagnan commented 3 years ago

Hello @noezad ,

This version seems to work.

What exactly is the search in your expression? It doesn't look to be provided in the parameter. So perhaps the issue is something else and that would explain why that's working for us.

JonathanMagnan commented 3 years ago

If you still have the problem, it is possible for you to provide a runnable project with the minimum code to reproduce the problem?

It will greatly help us to fix it instead of trying to reproduce it.

Best Regards,

Jon

noezad commented 3 years ago

Hello Sir , Yes, this problem is not solved yet, I will try to share with you a small project that has this problem in the next 2 days.

Tnx

Noezad

noezad commented 3 years ago

Done!

string searchText='"' + "test" + '*' + '"'; string query="c =>EF.Functions.FreeText(c.UseInSearch," + searchText + ") && c.IsDelete == false"; var allEvent = await (from n in _context.Events .WhereDynamic(query)...

Best Regards,

Noezad

JonathanMagnan commented 3 years ago

Awesome,

If I understand correctly, everything is now working?

It's also possible to pass parameter with an anonymous type:

var list = ctx.WhereDynamic(x => "x > y", new { y = 2 }).ToList();