Home > Net >  Parsing, bool Func <T> object into Expression <Func <T, bool> object
Parsing, bool Func <T> object into Expression <Func <T, bool> object

Time:11-16

Recently the underlying all use the EFCORE project, but in practice found Func As a condition for the query is a full table scan, now don't want to a wide range of change of the underlying, want to know how to can be flexible, here is my question 2:

The question a, direct conversion?
Func Transforming Expression< object; Func Objects?

Question 2, you cannot convert how to parse?

Func Object is parsed into Expression Objects?

CodePudding user response:

You can put the Expression As a source code while Func As the machine code,
Compile a good implementation, decompiled is difficult,

And even if you rewrite into Expression , EF can perform does not necessarily, EF can perform only a subset of expressions, such as many lines of code, loops, if judgment, conditional branch, call native functions, is not actually EF all support,

CodePudding user response:

Do not change the underlying, so suggest directly discarded,

CodePudding user response:

refer to the second floor interacting in a professional developer response:
do not change the underlying, so suggest directly dereference,


I changed the way:
Do not directly use delegate variable expression, direct use expressions. The Compile () method will also realized in reverse, but changes a lot more than before,

CodePudding user response:

reference 1/f, guiyang horse Ma Shanfu plugging waterproof engineering professional maintenance of swimming pool response:
you can put the Expression As a source code while Func As the machine code,
Compile a good implementation, decompiled is difficult,

And even if you rewrite into Expression , EF can perform does not necessarily, EF can perform only a subset of expressions, such as many lines of code, loops, if judgment, conditional branch, call native functions, the EF don't support actually,


Thank you for your detailed explanation,

CodePudding user response:

Expression Is a positive solution,
Light use Func pass, it's a full table scan first, then into Func filtering,
Through the expression tree, func can be spliced into SQL,
You look at the
https://blog.csdn.net/hanjun0612/article/details/62887466

CodePudding user response:

Yes, that's because of this I am going to put the underlying Func The parameters of all Expression The,

CodePudding user response:

refer to 6th floor hengren4 response:
yes, is because of this I am going to put the underlying Func The parameters of all Expression ,


Write a lambda change my good, change parameters more difficult,

CodePudding user response:

The zha to write? Trouble to give directions, thank you