got rid of generic depedancy. :)
This commit is contained in:
parent
c4a398a8cb
commit
18a3756f51
@ -11,19 +11,17 @@ namespace PoweredSoft.DynamicLinq.EntityFramework
|
|||||||
{
|
{
|
||||||
public static class DbContextExtensions
|
public static class DbContextExtensions
|
||||||
{
|
{
|
||||||
private static readonly MethodInfo QueryMethod = typeof(DbContextExtensions)
|
public static IQueryable Query(this DbContext context, Type pocoType, Action<WhereBuilder> callback)
|
||||||
.GetMethods(BindingFlags.Static | BindingFlags.Public)
|
|
||||||
.First(t => t.Name == "Query" && t.IsGenericMethod);
|
|
||||||
|
|
||||||
public static IQueryable Query(this DbContext context, Type pocoType, Action<WhereBuilderBase> callback)
|
|
||||||
{
|
{
|
||||||
var method = QueryMethod.MakeGenericMethod(pocoType);
|
var set = context.Set(pocoType);
|
||||||
var invokeResult = method.Invoke(null, new object[] {context, callback});
|
var queryable = set.AsQueryable();
|
||||||
var ret = invokeResult as IQueryable;
|
var builder = new WhereBuilder(queryable);
|
||||||
return ret;
|
callback(builder);
|
||||||
|
var result = builder.Build();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IQueryable<T> Query<T>(this DbContext context, Action<WhereBuilderBase> callback)
|
public static IQueryable<T> Query<T>(this DbContext context, Action<WhereBuilder> callback)
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
var query = context.Set<T>().AsQueryable();
|
var query = context.Set<T>().AsQueryable();
|
||||||
@ -31,10 +29,10 @@ namespace PoweredSoft.DynamicLinq.EntityFramework
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IQueryable Where(this DbContext context, Type pocoType, Action<WhereBuilderBase> callback)
|
public static IQueryable Where(this DbContext context, Type pocoType, Action<WhereBuilder> callback)
|
||||||
=> context.Query(pocoType, callback);
|
=> context.Query(pocoType, callback);
|
||||||
|
|
||||||
public static IQueryable<T> Where<T>(this DbContext context, Action<WhereBuilderBase> callback)
|
public static IQueryable<T> Where<T>(this DbContext context, Action<WhereBuilder> callback)
|
||||||
where T : class => context.Query<T>(callback);
|
where T : class => context.Query<T>(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace PoweredSoft.DynamicLinq.Test
|
|||||||
|
|
||||||
// the query.
|
// the query.
|
||||||
var query = posts.AsQueryable();
|
var query = posts.AsQueryable();
|
||||||
var queryBuilder = new WhereBuilder<Post>(query);
|
var queryBuilder = new WhereBuilder(query);
|
||||||
|
|
||||||
queryBuilder.Compare("AuthorId", ConditionOperators.Equal, 1);
|
queryBuilder.Compare("AuthorId", ConditionOperators.Equal, 1);
|
||||||
queryBuilder.And(subQuery =>
|
queryBuilder.And(subQuery =>
|
||||||
@ -65,7 +65,7 @@ namespace PoweredSoft.DynamicLinq.Test
|
|||||||
subQuery.Or("Title", ConditionOperators.Contains, 3);
|
subQuery.Or("Title", ConditionOperators.Contains, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
query = queryBuilder.Build();
|
query = (IQueryable<Post>)queryBuilder.Build();
|
||||||
Assert.AreEqual(2, query.Count());
|
Assert.AreEqual(2, query.Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ namespace PoweredSoft.DynamicLinq
|
|||||||
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> list.AsQueryable().Where(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> list.AsQueryable().Where(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public static IEnumerable<T> Where<T>(this IEnumerable<T> list, Action<WhereBuilder<T>> callback)
|
public static IEnumerable<T> Where<T>(this IEnumerable<T> list, Action<WhereBuilder> callback)
|
||||||
=> list.Query(callback);
|
=> list.Query(callback);
|
||||||
|
|
||||||
public static IEnumerable<T> Query<T>(this IEnumerable<T> list, Action<WhereBuilder<T>> callback)
|
public static IEnumerable<T> Query<T>(this IEnumerable<T> list, Action<WhereBuilder> callback)
|
||||||
=> list.AsQueryable().Query(callback);
|
=> list.AsQueryable().Query(callback);
|
||||||
|
|
||||||
public static IEnumerable<T> Sort<T>(this IEnumerable<T> list, string path, QueryOrderByDirection sortDirection, bool appendSort)
|
public static IEnumerable<T> Sort<T>(this IEnumerable<T> list, string path, QueryOrderByDirection sortDirection, bool appendSort)
|
||||||
|
@ -19,15 +19,15 @@ namespace PoweredSoft.DynamicLinq
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IQueryable<T> Where<T>(this IQueryable<T> query, Action<WhereBuilder<T>> callback)
|
public static IQueryable<T> Where<T>(this IQueryable<T> query, Action<WhereBuilder> callback)
|
||||||
=> query.Query(callback);
|
=> query.Query(callback);
|
||||||
|
|
||||||
public static IQueryable<T> Query<T> (this IQueryable<T> query, Action<WhereBuilder<T>> callback)
|
public static IQueryable<T> Query<T> (this IQueryable<T> query, Action<WhereBuilder> callback)
|
||||||
{
|
{
|
||||||
var queryBuilder = new WhereBuilder<T>(query);
|
var queryBuilder = new WhereBuilder(query);
|
||||||
callback(queryBuilder);
|
callback(queryBuilder);
|
||||||
var ret = queryBuilder.Build();
|
var ret = queryBuilder.Build();
|
||||||
return ret;
|
return (IQueryable<T>)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generic.
|
// generic.
|
||||||
|
@ -8,16 +8,64 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PoweredSoft.DynamicLinq.Fluent
|
namespace PoweredSoft.DynamicLinq.Fluent
|
||||||
{
|
{
|
||||||
public class WhereBuilder<T> : WhereBuilderBase
|
public partial class WhereBuilder
|
||||||
{
|
{
|
||||||
public IQueryable<T> Query { get; set; }
|
public IQueryable Query { get; set; }
|
||||||
|
public Type QueryableType { get; set; }
|
||||||
public WhereBuilder(IQueryable<T> query)
|
public List<WhereBuilderCondition> Filters { get; protected set; } = new List<WhereBuilderCondition>();
|
||||||
|
|
||||||
|
public WhereBuilder(IQueryable query)
|
||||||
{
|
{
|
||||||
Query = query;
|
Query = query;
|
||||||
|
QueryableType = query.ElementType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IQueryable<T> Build()
|
public bool IsNullCheckingEnabled { get; protected set; } = false;
|
||||||
|
|
||||||
|
public virtual WhereBuilder NullChecking(bool check = true)
|
||||||
|
{
|
||||||
|
IsNullCheckingEnabled = check;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual WhereBuilder Compare(string path, ConditionOperators conditionOperators, object value,
|
||||||
|
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField,
|
||||||
|
bool and = true, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
|
{
|
||||||
|
Filters.Add(new WhereBuilderCondition
|
||||||
|
{
|
||||||
|
And = and,
|
||||||
|
ConditionOperator = conditionOperators,
|
||||||
|
Path = path,
|
||||||
|
Value = value,
|
||||||
|
ConvertStrategy = convertStrategy,
|
||||||
|
CollectionHandling = collectionHandling,
|
||||||
|
StringComparisation = stringComparision
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual WhereBuilder SubQuery(Action<WhereBuilder> subQuery, bool and = true)
|
||||||
|
{
|
||||||
|
// create query builder for same type.
|
||||||
|
var qb = new WhereBuilder(Query);
|
||||||
|
qb.NullChecking(IsNullCheckingEnabled);
|
||||||
|
|
||||||
|
// callback.
|
||||||
|
subQuery(qb);
|
||||||
|
|
||||||
|
// create a query part.
|
||||||
|
var part = new WhereBuilderCondition();
|
||||||
|
part.And = and;
|
||||||
|
part.Conditions = qb.Filters;
|
||||||
|
Filters.Add(part);
|
||||||
|
|
||||||
|
//return self.
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual IQueryable Build()
|
||||||
{
|
{
|
||||||
// the query.
|
// the query.
|
||||||
var query = Query;
|
var query = Query;
|
||||||
@ -26,30 +74,31 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
return query;
|
return query;
|
||||||
|
|
||||||
// shared parameter.
|
// shared parameter.
|
||||||
var sharedParameter = Expression.Parameter(typeof(T), "t");
|
var sharedParameter = Expression.Parameter(QueryableType, "t");
|
||||||
|
|
||||||
// build the expression.
|
// build the expression.
|
||||||
var filterExpressionMerged = BuildFilterExpression(sharedParameter, Filters);
|
var filterExpressionMerged = BuildConditionExpression(sharedParameter, Filters);
|
||||||
|
|
||||||
// make changes on the query.
|
// create the where expression.
|
||||||
query = query.Where(filterExpressionMerged);
|
var whereExpression = Expression.Call(typeof(Queryable), "Where", new[] { query.ElementType }, query.Expression, filterExpressionMerged);
|
||||||
|
|
||||||
|
// lets see what happens here.
|
||||||
|
query = query.Provider.CreateQuery(whereExpression);
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Expression<Func<T, bool>> BuildFilterExpression(ParameterExpression parameter, List<WhereBuilderCondition> filters)
|
protected virtual Expression BuildConditionExpression(ParameterExpression parameter, List<WhereBuilderCondition> filters)
|
||||||
{
|
{
|
||||||
Expression<Func<T, bool>> temp = null;
|
Expression temp = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
filters.ForEach(filter =>
|
filters.ForEach(filter =>
|
||||||
{
|
{
|
||||||
Expression<Func<T, bool>> innerExpression;
|
Expression innerExpression;
|
||||||
if (filter.Conditions?.Any() == true)
|
if (filter.Conditions?.Any() == true)
|
||||||
innerExpression = BuildFilterExpression(parameter, filter.Conditions);
|
innerExpression = BuildConditionExpression(parameter, filter.Conditions);
|
||||||
else
|
else
|
||||||
innerExpression = BuildFilterExpression(parameter, filter);
|
innerExpression = BuildConditionExpression(parameter, filter);
|
||||||
|
|
||||||
if (temp == null)
|
if (temp == null)
|
||||||
{
|
{
|
||||||
@ -57,10 +106,13 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var body = ((LambdaExpression)temp).Body;
|
||||||
|
var innerEpressionBody = ((LambdaExpression)innerExpression).Body;
|
||||||
|
|
||||||
if (filter.And)
|
if (filter.And)
|
||||||
temp = Expression.Lambda<Func<T, bool>>(Expression.AndAlso(temp.Body, innerExpression.Body), parameter);
|
temp = Expression.Lambda(Expression.AndAlso(body, innerEpressionBody), parameter);
|
||||||
else
|
else
|
||||||
temp = Expression.Lambda<Func<T, bool>>(Expression.OrElse(temp.Body, innerExpression.Body), parameter);
|
temp = Expression.Lambda(Expression.OrElse(body, innerEpressionBody), parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -68,9 +120,10 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Expression<Func<T, bool>> BuildFilterExpression(ParameterExpression parameter, WhereBuilderCondition filter)
|
protected virtual Expression BuildConditionExpression(ParameterExpression parameter, WhereBuilderCondition filter)
|
||||||
{
|
{
|
||||||
var ret = QueryableHelpers.CreateConditionExpression<T>(
|
var ret = QueryableHelpers.CreateConditionExpression(
|
||||||
|
parameter.Type,
|
||||||
filter.Path,
|
filter.Path,
|
||||||
filter.ConditionOperator,
|
filter.ConditionOperator,
|
||||||
filter.Value,
|
filter.Value,
|
||||||
@ -83,10 +136,5 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override WhereBuilderBase GetSubQueryBuilder()
|
|
||||||
{
|
|
||||||
return new WhereBuilder<T>(Query);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,140 +4,140 @@ using System.Text;
|
|||||||
|
|
||||||
namespace PoweredSoft.DynamicLinq.Fluent
|
namespace PoweredSoft.DynamicLinq.Fluent
|
||||||
{
|
{
|
||||||
public abstract partial class WhereBuilderBase
|
public partial class WhereBuilder
|
||||||
{
|
{
|
||||||
public WhereBuilderBase And(string path, ConditionOperators conditionOperator, object value,
|
public WhereBuilder And(string path, ConditionOperators conditionOperator, object value,
|
||||||
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, and: true, stringComparision: stringComparision);
|
=> Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, and: true, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase Or(string path, ConditionOperators conditionOperator, object value,
|
public WhereBuilder Or(string path, ConditionOperators conditionOperator, object value,
|
||||||
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, and: false, stringComparision: stringComparision);
|
=> Compare(path, conditionOperator, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, and: false, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase And(Action<WhereBuilderBase> subQuery)
|
public WhereBuilder And(Action<WhereBuilder> subQuery)
|
||||||
=> SubQuery(subQuery, true);
|
=> SubQuery(subQuery, true);
|
||||||
|
|
||||||
public WhereBuilderBase Or(Action<WhereBuilderBase> subQuery)
|
public WhereBuilder Or(Action<WhereBuilder> subQuery)
|
||||||
=> SubQuery(subQuery, false);
|
=> SubQuery(subQuery, false);
|
||||||
|
|
||||||
#region equal
|
#region equal
|
||||||
public WhereBuilderBase Equal(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder Equal(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase AndEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase OrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Or(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.Equal, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region not equal
|
#region not equal
|
||||||
public WhereBuilderBase NotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder NotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase AndNotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndNotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase OrNotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrNotEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Or(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.NotEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GreaterThan
|
#region GreaterThan
|
||||||
public WhereBuilderBase GreaterThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder GreaterThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> And(path, ConditionOperators.GreaterThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> And(path, ConditionOperators.GreaterThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
|
|
||||||
public WhereBuilderBase AndGreaterThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder AndGreaterThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> And(path, ConditionOperators.GreaterThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> And(path, ConditionOperators.GreaterThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
|
|
||||||
public WhereBuilderBase OrGreaterThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder OrGreaterThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> Or(path, ConditionOperators.GreaterThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> Or(path, ConditionOperators.GreaterThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GreaterThanOrEqual
|
#region GreaterThanOrEqual
|
||||||
public WhereBuilderBase GreaterThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder GreaterThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> And(path, ConditionOperators.GreaterThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> And(path, ConditionOperators.GreaterThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
|
|
||||||
public WhereBuilderBase AndGreaterThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder AndGreaterThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> And(path, ConditionOperators.GreaterThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> And(path, ConditionOperators.GreaterThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
|
|
||||||
public WhereBuilderBase OrGreaterThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder OrGreaterThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> Or(path, ConditionOperators.GreaterThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> Or(path, ConditionOperators.GreaterThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region LessThan
|
#region LessThan
|
||||||
public WhereBuilderBase LessThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder LessThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> And(path, ConditionOperators.LessThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> And(path, ConditionOperators.LessThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
|
|
||||||
public WhereBuilderBase AndLessThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder AndLessThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> And(path, ConditionOperators.LessThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> And(path, ConditionOperators.LessThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
|
|
||||||
public WhereBuilderBase OrLessThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder OrLessThan(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> Or(path, ConditionOperators.LessThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> Or(path, ConditionOperators.LessThan, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region LessThanOrEqual
|
#region LessThanOrEqual
|
||||||
public WhereBuilderBase LessThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder LessThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> And(path, ConditionOperators.LessThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> And(path, ConditionOperators.LessThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
|
|
||||||
public WhereBuilderBase AndLessThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder AndLessThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> And(path, ConditionOperators.LessThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> And(path, ConditionOperators.LessThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
|
|
||||||
public WhereBuilderBase OrLessThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
public WhereBuilder OrLessThanOrEqual(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any)
|
||||||
=> Or(path, ConditionOperators.LessThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
=> Or(path, ConditionOperators.LessThanOrEqual, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region contains
|
#region contains
|
||||||
public WhereBuilderBase Contains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder Contains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase AndContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase OrContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrContains(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Or(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.Contains, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region starts with
|
#region starts with
|
||||||
public WhereBuilderBase StartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder StartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase AndStartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndStartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase OrStartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrStartsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Or(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.StartsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ends with
|
#region ends with
|
||||||
public WhereBuilderBase EndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder EndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase AndEndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndEndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase OrEndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrEndsWith(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Or(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.EndsWith, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region In
|
#region In
|
||||||
public WhereBuilderBase In(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder In(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.In, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.In, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase AndIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.In, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.In, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase OrIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Or(path, ConditionOperators.In, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.In, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region NotIn
|
#region NotIn
|
||||||
public WhereBuilderBase NotIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder NotIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.NotIn, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.NotIn, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase AndNotIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder AndNotIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> And(path, ConditionOperators.NotIn, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> And(path, ConditionOperators.NotIn, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
|
|
||||||
public WhereBuilderBase OrNotIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
public WhereBuilder OrNotIn(string path, object value, QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
||||||
=> Or(path, ConditionOperators.NotIn, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
=> Or(path, ConditionOperators.NotIn, value, convertStrategy: convertStrategy, collectionHandling: collectionHandling, stringComparision: stringComparision);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
@ -1,61 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.CodeDom;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PoweredSoft.DynamicLinq.Fluent
|
|
||||||
{
|
|
||||||
public abstract partial class WhereBuilderBase
|
|
||||||
{
|
|
||||||
public bool IsNullCheckingEnabled { get; protected set; } = false;
|
|
||||||
|
|
||||||
public List<WhereBuilderCondition> Filters { get; protected set; } = new List<WhereBuilderCondition>();
|
|
||||||
|
|
||||||
public virtual WhereBuilderBase NullChecking(bool check = true)
|
|
||||||
{
|
|
||||||
IsNullCheckingEnabled = check;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual WhereBuilderBase Compare(string path, ConditionOperators conditionOperators, object value,
|
|
||||||
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField,
|
|
||||||
bool and = true, QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any, StringComparison? stringComparision = null)
|
|
||||||
{
|
|
||||||
Filters.Add(new WhereBuilderCondition
|
|
||||||
{
|
|
||||||
And = and,
|
|
||||||
ConditionOperator = conditionOperators,
|
|
||||||
Path = path,
|
|
||||||
Value = value,
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
CollectionHandling = collectionHandling,
|
|
||||||
StringComparisation = stringComparision
|
|
||||||
});
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract WhereBuilderBase GetSubQueryBuilder();
|
|
||||||
|
|
||||||
public virtual WhereBuilderBase SubQuery(Action<WhereBuilderBase> subQuery, bool and = true)
|
|
||||||
{
|
|
||||||
// create query builder for same type.
|
|
||||||
var qb = GetSubQueryBuilder();
|
|
||||||
qb.NullChecking(IsNullCheckingEnabled);
|
|
||||||
|
|
||||||
// callback.
|
|
||||||
subQuery(qb);
|
|
||||||
|
|
||||||
// create a query part.
|
|
||||||
var part = new WhereBuilderCondition();
|
|
||||||
part.And = and;
|
|
||||||
part.Conditions = qb.Filters;
|
|
||||||
Filters.Add(part);
|
|
||||||
|
|
||||||
//return self.
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -79,6 +79,8 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static IQueryable GroupBy(IQueryable query, Type type, List<(string path, string propertyName)> parts, Type groupToType = null, Type equalityCompareType = null)
|
public static IQueryable GroupBy(IQueryable query, Type type, List<(string path, string propertyName)> parts, Type groupToType = null, Type equalityCompareType = null)
|
||||||
{
|
{
|
||||||
// EXPRESSION
|
// EXPRESSION
|
||||||
@ -270,16 +272,16 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
throw new NotSupportedException($"{convertStrategy} supplied is not recognized");
|
throw new NotSupportedException($"{convertStrategy} supplied is not recognized");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IQueryable CreateOrderByExpression(IQueryable query, string sortPath, QueryOrderByDirection sortDirection, bool appendSort = true)
|
public static IQueryable CreateOrderByExpression(IQueryable query, string path, QueryOrderByDirection direction, bool append = true)
|
||||||
{
|
{
|
||||||
var parameter = Expression.Parameter(query.ElementType, "t");
|
var parameter = Expression.Parameter(query.ElementType, "t");
|
||||||
var member = QueryableHelpers.ResolvePathForExpression(parameter, sortPath);
|
var member = QueryableHelpers.ResolvePathForExpression(parameter, path);
|
||||||
|
|
||||||
string sortCommand = null;
|
string sortCommand = null;
|
||||||
if (sortDirection == QueryOrderByDirection.Descending)
|
if (direction == QueryOrderByDirection.Descending)
|
||||||
sortCommand = appendSort == false ? "OrderByDescending" : "ThenByDescending";
|
sortCommand = append == false ? "OrderByDescending" : "ThenByDescending";
|
||||||
else
|
else
|
||||||
sortCommand = appendSort == false ? "OrderBy" : "ThenBy";
|
sortCommand = append == false ? "OrderBy" : "ThenBy";
|
||||||
|
|
||||||
var expression = Expression.Lambda(member, parameter);
|
var expression = Expression.Lambda(member, parameter);
|
||||||
|
|
||||||
@ -420,9 +422,27 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
throw new NotSupportedException($"{collectionHandling} is not supported");
|
throw new NotSupportedException($"{collectionHandling} is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Expression<Func<T, bool>> CreateConditionExpression<T>(string path,
|
public static Expression<Func<T, bool>> CreateConditionExpression<T>(
|
||||||
|
string path,
|
||||||
|
ConditionOperators condition,
|
||||||
|
object value,
|
||||||
|
QueryConvertStrategy convertStrategy,
|
||||||
|
QueryCollectionHandling collectionHandling = QueryCollectionHandling.Any,
|
||||||
|
ParameterExpression parameter = null,
|
||||||
|
bool nullChecking = false,
|
||||||
|
StringComparison? stringComparision = null)
|
||||||
|
{
|
||||||
|
var ret = CreateConditionExpression(typeof(T), path, condition, value, convertStrategy,
|
||||||
|
collectionHandling: collectionHandling,
|
||||||
|
parameter: parameter,
|
||||||
|
nullChecking: nullChecking,
|
||||||
|
stringComparision: stringComparision) as Expression<Func<T, bool>>;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Expression CreateConditionExpression(Type type,
|
||||||
|
string path,
|
||||||
ConditionOperators condition,
|
ConditionOperators condition,
|
||||||
object value,
|
object value,
|
||||||
QueryConvertStrategy convertStrategy,
|
QueryConvertStrategy convertStrategy,
|
||||||
@ -432,12 +452,11 @@ namespace PoweredSoft.DynamicLinq.Helpers
|
|||||||
StringComparison? stringComparision = null)
|
StringComparison? stringComparision = null)
|
||||||
{
|
{
|
||||||
if (parameter == null)
|
if (parameter == null)
|
||||||
parameter = Expression.Parameter(typeof(T), "t");
|
parameter = Expression.Parameter(type, "t");
|
||||||
|
|
||||||
var parts = path.Split('.').ToList();
|
var parts = path.Split('.').ToList();
|
||||||
var result = InternalCreateConditionExpression(1, typeof(T), parameter, parameter, parts, condition, value, convertStrategy, collectionHandling, nullChecking, stringComparision);
|
var result = InternalCreateConditionExpression(1, type, parameter, parameter, parts, condition, value, convertStrategy, collectionHandling, nullChecking, stringComparision);
|
||||||
var ret = result as Expression<Func<T, bool>>;
|
return result;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsEnumerable(MemberExpression member)
|
public static bool IsEnumerable(MemberExpression member)
|
||||||
|
Loading…
Reference in New Issue
Block a user