changed types to use string to avoid enumeration issues.

This commit is contained in:
David Lebee 2021-02-08 23:38:35 -05:00
parent 777074f54a
commit 3020fbf126
3 changed files with 29 additions and 5 deletions

View File

@ -33,14 +33,14 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore
public int? Page { get; set; }
public int? PageSize { get; set; }
public List<Sort> Sorts { get; set; }
public List<Aggregate> Aggregates { get; set; }
public List<DynamicQueryAggregate> Aggregates { get; set; }
public List<Group> Groups { get; set; }
public List<DynamicQueryFilter> Filters { get; set; }
public List<IAggregate> GetAggregates()
{
return Aggregates?.AsEnumerable<IAggregate>()?.ToList();
return Aggregates?.Select(t => t.ToAggregate())?.ToList();//.AsEnumerable<IAggregate>()?.ToList();
}
public List<IFilter> GetFilters()

View File

@ -0,0 +1,22 @@
using PoweredSoft.DynamicQuery;
using PoweredSoft.DynamicQuery.Core;
using System;
namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore
{
public class DynamicQueryAggregate
{
public string Path { get; set; }
public string Type { get; set; }
public IAggregate ToAggregate()
{
return new Aggregate
{
Type = Enum.Parse<AggregateType>(Type),
Path = Path
};
}
}
}

View File

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using PoweredSoft.DynamicQuery;
using PoweredSoft.DynamicQuery.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
@ -11,7 +12,7 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore
{
public List<DynamicQueryFilter> Filters { get; set; }
public bool? And { get; set; }
public FilterType Type { get; set; }
public string Type { get; set; }
public bool? Not { get; set; }
public string Path { get; set; }
public object Value { get; set; }
@ -31,7 +32,8 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore
public IFilter ToFilter()
{
if (Type == FilterType.Composite)
var type = Enum.Parse<FilterType>(Type);
if (type == FilterType.Composite)
{
var compositeFilter = new CompositeFilter
{
@ -62,7 +64,7 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore
var simpleFilter = new SimpleFilter
{
And = And,
Type = Type,
Type = type,
Not = Not,
Path = Path,
Value = value