0

Hi guys I need some like php eval function to run piece of code that is storage in the DataBase, like:

"UidAsLong == 18" or "Name.Equals('Visa')" .

So, I have to check if these piece of code match with an object, like PaymentInfo, so if PaymentInfo.UidAsLong == 18 the function may return true, or if the name equals Visa...

These piece of code in database can assume any C# attribute comparison expression, so, I need a function like CheckMatch(object payment, string stringToCheck) that returns me True or false.

Thanks

Rodrigo
  • 188
  • 1
  • 8
  • 1
    have a look this question https://stackoverflow.com/questions/4629/how-can-i-evaluate-c-sharp-code-dynamically – Dezigo Sep 23 '21 at 18:50
  • In short, No. You either need to a. write a parser or b. somehow compile your code snippets at runtime. If you go with route b, [Roslyn](https://github.com/dotnet/roslyn) might be helpful to look into. – RoadieRich Sep 23 '21 at 18:54
  • Or Dynamic Linq? – Caius Jard Sep 23 '21 at 19:16

0 Answers0