dbelmont / ExpressionBuilder

A library that provides a simple way to create lambda expressions to filter lists and database queries.
Apache License 2.0
372 stars 105 forks source link

Convert "Filter" to Native .NET Expression.Lambda #34

Closed lousadacbc closed 6 years ago

lousadacbc commented 6 years ago

Hello everyone,

I would like to use this nuget, it's very good. But I did not want my data layer to depend directly on it. Is there any way to do a caste or convert "Filter" to Native .NET Expression.Lambda?

Thank you

dbelmont commented 6 years ago

Hi @lousadacbc, Many thanks for using the project! 😄 Sorry for the late reply. You can actually implicitly convert it to Expression<Func<TClass, bool>> by doing something like this:

var filter = new Filter<Person>();
//...
var expr = (Expression<Func<Person, bool>>)filter;