convert lambda expression for where clause

Mar 31, 2010 at 12:22 PM

I have code that basically builds up insert, update and delete statements from a model in C#.

I am wanting the ability to pass in a lambda expression that can be used as the where clause for my generated sql text, but am unsure as to if this is possible using your toolkit?

The form of the expression is as follows (for the model staff):

Expression<Func<staff, bool>> whereClause = s => s.staff_id_ == "ME";

So basically I am wanting  "staff.staff_id = 'ME'" to be returned, so that I can append it to the rest of the sql statement.

I was then trying to pass this into the SqlFormatter.Format method, but it just exceptions.

Am I on the right lines at all, or is what I am trying to achieve not possible. Also, if you can think of a better way to achieve what I want, please let me know.

Thanks in advance.