Skip to content

Instantly share code, notes, and snippets.

View teleginski's full-sized avatar

Willian Teleginski teleginski

  • Curitiba - Brasil
View GitHub Profile
@teleginski
teleginski / ExpressionBuilder.cs
Last active June 5, 2024 16:11
C# .NET - Expression Builder - Dynamic Filter - Dynamic Where
public static class ExpressionBuilder
{
private static readonly MethodInfo containsMethod = typeof(string).GetMethod("Contains");
private static readonly MethodInfo toLowerMethod = typeof(string).GetMethod("ToLower", new Type[0] { });
public static Func<T, bool> GetExpression<T>(IList<Filter> filters)
{
ParameterExpression parameter = Expression.Parameter(typeof(T), "t");
Expression expression = null;