renamed.
This commit is contained in:
parent
571ef78e86
commit
a3139cb892
@ -14,7 +14,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
|
|
||||||
public Type QueryableType { get; set; }
|
public Type QueryableType { get; set; }
|
||||||
|
|
||||||
public List<QueryFilterPart> Parts { get; protected set; } = new List<QueryFilterPart>();
|
public List<QueryBuilderFilter> Parts { get; protected set; } = new List<QueryBuilderFilter>();
|
||||||
|
|
||||||
public QueryBuilder(IQueryable<T> query)
|
public QueryBuilder(IQueryable<T> query)
|
||||||
{
|
{
|
||||||
@ -25,7 +25,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField,
|
QueryConvertStrategy convertStrategy = QueryConvertStrategy.ConvertConstantToComparedPropertyOrField,
|
||||||
bool and = true)
|
bool and = true)
|
||||||
{
|
{
|
||||||
Parts.Add(new QueryFilterPart
|
Parts.Add(new QueryBuilderFilter
|
||||||
{
|
{
|
||||||
And = and,
|
And = and,
|
||||||
ConditionOperator = conditionOperators,
|
ConditionOperator = conditionOperators,
|
||||||
@ -46,7 +46,7 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
subQuery(qb);
|
subQuery(qb);
|
||||||
|
|
||||||
// create a query part.
|
// create a query part.
|
||||||
var part = new QueryFilterPart();
|
var part = new QueryBuilderFilter();
|
||||||
part.And = and;
|
part.And = and;
|
||||||
part.Parts = qb.Parts;
|
part.Parts = qb.Parts;
|
||||||
Parts.Add(part);
|
Parts.Add(part);
|
||||||
@ -88,20 +88,20 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Expression BuildFilterExpression(ParameterExpression parameter, List<QueryFilterPart> parts)
|
protected virtual Expression BuildFilterExpression(ParameterExpression parameter, List<QueryBuilderFilter> filters)
|
||||||
{
|
{
|
||||||
Expression ret = null;
|
Expression ret = null;
|
||||||
|
|
||||||
parts.ForEach(part =>
|
filters.ForEach(filter =>
|
||||||
{
|
{
|
||||||
Expression innerExpression;
|
Expression innerExpression;
|
||||||
if (part.Parts?.Any() == true)
|
if (filter.Parts?.Any() == true)
|
||||||
innerExpression = BuildFilterExpression(parameter, part.Parts);
|
innerExpression = BuildFilterExpression(parameter, filter.Parts);
|
||||||
else
|
else
|
||||||
innerExpression = BuildFilterExpression(parameter, part);
|
innerExpression = BuildFilterExpression(parameter, filter);
|
||||||
|
|
||||||
if (ret != null)
|
if (ret != null)
|
||||||
ret = part.And ? Expression.And(ret, innerExpression) : Expression.Or(ret, innerExpression);
|
ret = filter.And ? Expression.And(ret, innerExpression) : Expression.Or(ret, innerExpression);
|
||||||
else
|
else
|
||||||
ret = innerExpression;
|
ret = innerExpression;
|
||||||
});
|
});
|
||||||
@ -109,11 +109,11 @@ namespace PoweredSoft.DynamicLinq.Fluent
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Expression BuildFilterExpression(ParameterExpression parameter, QueryFilterPart part)
|
protected virtual Expression BuildFilterExpression(ParameterExpression parameter, QueryBuilderFilter filter)
|
||||||
{
|
{
|
||||||
var member = QueryableHelpers.ResolvePathForExpression(parameter, part.Path);
|
var member = QueryableHelpers.ResolvePathForExpression(parameter, filter.Path);
|
||||||
var constant = QueryableHelpers.ResolveConstant(member, part.Value, part.ConvertStrategy);
|
var constant = QueryableHelpers.ResolveConstant(member, filter.Value, filter.ConvertStrategy);
|
||||||
var expression = QueryableHelpers.GetConditionExpressionForMember(parameter, member, part.ConditionOperator, constant);
|
var expression = QueryableHelpers.GetConditionExpressionForMember(parameter, member, filter.ConditionOperator, constant);
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PoweredSoft.DynamicLinq.Fluent
|
namespace PoweredSoft.DynamicLinq.Fluent
|
||||||
{
|
{
|
||||||
public class QueryFilterPart
|
public class QueryBuilderFilter
|
||||||
{
|
{
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public ConditionOperators ConditionOperator { get; set; }
|
public ConditionOperators ConditionOperator { get; set; }
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
public bool And { get; set; }
|
public bool And { get; set; }
|
||||||
public QueryConvertStrategy ConvertStrategy { get; set; }
|
public QueryConvertStrategy ConvertStrategy { get; set; }
|
||||||
public List<QueryFilterPart> Parts { get; set; } = new List<QueryFilterPart>();
|
public List<QueryBuilderFilter> Parts { get; set; } = new List<QueryBuilderFilter>();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -46,7 +46,7 @@
|
|||||||
<Compile Include="Helpers\TypeHelpers.cs" />
|
<Compile Include="Helpers\TypeHelpers.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Fluent\QueryBuilder.cs" />
|
<Compile Include="Fluent\QueryBuilder.cs" />
|
||||||
<Compile Include="Fluent\QueryFilterPart.cs" />
|
<Compile Include="Fluent\QueryBuilderFilter.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
Loading…
Reference in New Issue
Block a user