Shane Fulmer
Shane Fulmer

Reputation: 7708

Creating a string from a lambda expression

I have functions that take SQL where clauses, and I'm wondering if there's a way to make them all strongly typed. Is there a way to take a lambda expression like a => a.AgencyID == id and convert it to a string where clause? Like "AgencyID = 'idValue'"?

Thanks!

Upvotes: 4

Views: 368

Answers (1)

Gordon Tisher
Gordon Tisher

Reputation: 211

You could turn the lambda function into an expression tree, and then traverse the tree to build your string.

Upvotes: 3

Related Questions