using System.Linq.Expressions;
namespace ZeroFramework.DeviceCenter.Domain.Specifications
{
///
/// Encapsulates query logic for ,
/// and projects the result into .
///
/// The type being queried against.
/// The type of the result.
public interface ISpecification : ISpecification
{
///
/// The transform function to apply to the element.
///
Expression>? Selector { get; }
///
/// The transform function to apply to the result of the query encapsulated by the .
///
new Func, IEnumerable>? PostProcessingAction { get; }
new IEnumerable Evaluate(IEnumerable entities);
}
///
/// Encapsulates query logic for .
///
/// The type being queried against.
public interface ISpecification
{
///
/// The collection of predicates to filter on.
///
IEnumerable>> WhereExpressions { get; }
///
/// The collections of functions used to determine the sorting (and subsequent sorting),
/// to apply to the result of the query encapsulated by the .
/// KeySelector, a function to extract a key from an element.
/// OrderType, whether to (subsequently) sort ascending or descending
///
IEnumerable<(Expression> KeySelector, OrderTypeEnum OrderType)> OrderExpressions { get; }
///
/// The collection of s describing each include expression.
/// This information is utilized to build Include/ThenInclude functions in the query.
///
IEnumerable IncludeExpressions { get; }
///
/// The collection of navigation properties, as strings, to include in the query.
///
IEnumerable IncludeStrings { get; }
///
/// The collection of 'SQL LIKE' operations, constructed by;
///
/// - Selector, the property to apply the SQL LIKE against.
/// - SearchTerm, the value to use for the SQL LIKE.
/// - SearchGroup, the index used to group sets of Selectors and SearchTerms together.
///
///
IEnumerable<(Expression> Selector, string SearchTerm, int SearchGroup)> SearchCriterias { get; }
///
/// The number of elements to return.
///
int? Take { get; }
///
/// The number of elements to skip before returning the remaining elements.
///
int? Skip { get; }
///
/// The transform function to apply to the result of the query encapsulated by the .
///
Func, IEnumerable>? PostProcessingAction { get; }
///
/// Return whether or not the results should be cached.
///
bool CacheEnabled { get; }
///
/// The identifier to use to store and retrieve results from the cache.
///
string? CacheKey { get; }
///
/// Returns whether or not the change tracker will track any of the entities
/// that are returned. When true, if the entity instances are modified, this will not be detected
/// by the change tracker.
///
bool AsNoTracking { get; }
bool AsSplitQuery { get; }
bool AsNoTrackingWithIdentityResolution { get; }
IEnumerable Evaluate(IEnumerable entities);
}
}