dotnet-dynamic-query/PoweredSoft.DynamicQuery/QueryResult.cs

55 lines
1.7 KiB
C#
Raw Normal View History

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.
public abstract class QueryResult<TRecord> : IQueryResult<TRecord>
2018-10-18 21:52:05 -04:00
{
public List<IAggregateResult> Aggregates { get; set; }
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
}
// just result
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-03-22 16:27:04 -04:00
public class QueryExecutionGroupResult<TRecord> : QueryExecutionResult<TRecord>, IQueryExecutionGroupResult<TRecord>
{
public List<IGroupQueryResult<TRecord>> Groups { get; set; }
}
// group result.
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;
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
}
}