dotnet-dynamic-linq/PoweredSoft.DynamicLinq/Extensions/QueryableExtensions.cs

29 lines
1001 B
C#
Raw Normal View History

2018-02-11 20:55:29 -05:00
using PoweredSoft.DynamicLinq.Fluent;
using PoweredSoft.DynamicLinq.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace PoweredSoft.DynamicLinq.Extensions
{
public static class QueryableExtensions
{
public static IQueryable<T> Where<T>(this IQueryable<T> query, string path, ConditionOperators conditionOperator, object value, bool convertConstantToLeftOperator = true)
{
query = query.Query(qb => qb.Compare(path, conditionOperator, value, convertConstantToLeftOperator: convertConstantToLeftOperator));
return query;
}
public static IQueryable<T> Query<T> (this IQueryable<T> query, Action<QueryBuilder<T>> callback)
{
var queryBuilder = new QueryBuilder<T>(query);
callback(queryBuilder);
var ret = queryBuilder.Build();
return ret;
}
}
}