using System; using System.Collections.Generic; using System.Linq; using System.Text; using PoweredSoft.DynamicQuery.Core; namespace PoweredSoft.DynamicQuery { /// /// Represents an aggregate result. /// public class AggregateResult : IAggregateResult { public string Path { get; set; } public AggregateType Type { get; set; } public object Value { get; set; } public bool ShouldSerializePath() => !string.IsNullOrWhiteSpace(Path); } // part of a result. public abstract class QueryResult : IQueryResult { public List Aggregates { get; set; } public List Data { get; set; } public bool ShouldSerializeAggregates() => Aggregates != null; public bool ShouldSerializeData() => Data != null; } // just result public class QueryExecutionResult : QueryResult, IQueryExecutionResult { public long TotalRecords { get; set; } public long? NumberOfPages { get; set; } public bool ShouldSerializeNumberOfPages() => NumberOfPages.HasValue; } public class QueryExecutionGroupResult : QueryExecutionResult, IQueryExecutionGroupResult { public List> Groups { get; set; } } // group result. public class GroupQueryResult : QueryResult, IGroupQueryResult { public string GroupPath { get; set; } public object GroupValue { get; set; } public bool HasSubGroups => SubGroups != null && SubGroups.Count >= 1; public List> SubGroups { get; set; } public bool ShouldSerializeSubGroups() => HasSubGroups; } }