vendredi 19 mai 2017

How do I grab the Property name and compared value from an expression?

We use use filters at work which are a type

Expression < Func < T, bool > >

which we use like use with methods like:

GetItems < People >(x => x.SurName == "Smith");

I need to make a method that takes a Expression< Func < T, bool > > as a parameter, like shown above, and breaks it down into 3 values, a string "SurName" for the property, a string "==" to represent an equality comparison, and a string "Smith" for the value being compared too.

I managed to get the string "SurName" out of it, but I can't for the life of my figure out how to determine the type of comparison (equality) or the compared value ("Smith")





Aucun commentaire:

Enregistrer un commentaire