2018-10-18 21:52:05 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using PoweredSoft.DynamicQuery.Core;
|
|
|
|
|
|
|
|
|
|
namespace PoweredSoft.DynamicQuery
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents an aggregate result.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class AggregateResult : IAggregateResult
|
|
|
|
|
{
|
|
|
|
|
public string Path { get; set; }
|
|
|
|
|
public AggregateType Type { get; set; }
|
|
|
|
|
public object Value { get; set; }
|
2018-10-21 16:20:17 -04:00
|
|
|
|
|
|
|
|
|
public bool ShouldSerializePath() => !string.IsNullOrWhiteSpace(Path);
|
2018-10-18 21:52:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// part of a result.
|
2019-03-19 23:54:15 -04:00
|
|
|
|
public abstract class QueryResult<TRecord> : IQueryResult<TRecord>
|
2018-10-18 21:52:05 -04:00
|
|
|
|
{
|
|
|
|
|
public List<IAggregateResult> Aggregates { get; set; }
|
2019-03-19 23:54:15 -04:00
|
|
|
|
public List<TRecord> Data { get; set; }
|
2018-10-18 21:52:05 -04:00
|
|
|
|
|
|
|
|
|
public bool ShouldSerializeAggregates() => Aggregates != null;
|
2019-03-22 17:17:19 -04:00
|
|
|
|
|
|
|
|
|
public bool ShouldSerializeData() => Data != null;
|
2018-10-18 21:52:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-21 15:15:26 -04:00
|
|
|
|
// just result
|
2019-03-19 23:54:15 -04:00
|
|
|
|
public class QueryExecutionResult<TRecord> : QueryResult<TRecord>, IQueryExecutionResult<TRecord>
|
2018-10-18 21:52:05 -04:00
|
|
|
|
{
|
|
|
|
|
public long TotalRecords { get; set; }
|
|
|
|
|
public long? NumberOfPages { get; set; }
|
2019-09-05 22:22:50 -04:00
|
|
|
|
|
|
|
|
|
public bool ShouldSerializeNumberOfPages() => NumberOfPages.HasValue;
|
2018-10-18 21:52:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-22 16:27:04 -04:00
|
|
|
|
public class QueryExecutionGroupResult<TRecord> : QueryExecutionResult<TRecord>, IQueryExecutionGroupResult<TRecord>
|
2019-03-19 23:54:15 -04:00
|
|
|
|
{
|
|
|
|
|
public List<IGroupQueryResult<TRecord>> Groups { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-21 15:15:26 -04:00
|
|
|
|
// group result.
|
2019-03-19 23:54:15 -04:00
|
|
|
|
public class GroupQueryResult<TRecord> : QueryResult<TRecord>, IGroupQueryResult<TRecord>
|
2018-10-18 21:52:05 -04:00
|
|
|
|
{
|
|
|
|
|
public string GroupPath { get; set; }
|
|
|
|
|
public object GroupValue { get; set; }
|
2019-03-22 17:40:05 -04:00
|
|
|
|
public bool HasSubGroups => SubGroups != null && SubGroups.Count >= 1;
|
2019-03-19 23:54:15 -04:00
|
|
|
|
public List<IGroupQueryResult<TRecord>> SubGroups { get; set; }
|
2019-03-22 17:17:19 -04:00
|
|
|
|
|
|
|
|
|
public bool ShouldSerializeSubGroups() => HasSubGroups;
|
2018-10-18 21:52:05 -04:00
|
|
|
|
}
|
|
|
|
|
}
|