mercredi 16 mars 2022

Query an Object when you only have the field name

I am looking to build a Query based on the Property that is unknown. However, my problem is that the Property Name is passed through as a string and this can change anytime and there are alot of properties so i'm looking for something more elegant than a big if/switch statement.

I am looking to do something along the lines of (Where query is of type IQueryable and the object type is known):

property = typeof(xxx).GetProperty(propName);

query = query.Where(x => x.PassedThroughProperty == xx);

The query is for querying my Cosmos DB.

Thanks :)





Aucun commentaire:

Enregistrer un commentaire