/// <summary> /// Initializes a new instance of the <see cref="MorphableFlowQueryBase{TSource,TQuery}" /> class. /// </summary> /// <param name="criteriaFactory"> /// The criteria factory. /// </param> /// <param name="alias"> /// The alias. /// </param> /// <param name="options"> /// The options. /// </param> /// <param name="query"> /// The query. /// </param> /// <exception cref="ArgumentException"> /// The "this" reference is not of the type <see cref="T:TQuery" /> as specified by /// <typeparamref name="TQuery" />. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="criteriaFactory" /> is null and the specific query alteration is not an implementation /// of <see cref="T:IDetachedFlowQuery{TSource}" />. /// </exception> protected MorphableFlowQueryBase ( Func <Type, string, ICriteria> criteriaFactory, string alias = null, FlowQueryOptions options = null, IMorphableFlowQuery query = null ) : base(criteriaFactory, alias, options, query) { if (query != null) { CommentValue = query.CommentValue; Constructor = query.Constructor; FetchSizeValue = query.FetchSizeValue; IsDistinct = query.IsDistinct; IsReadOnly = query.IsReadOnly; if (query.Mappings != null) { Mappings = query.Mappings.ToDictionary(x => x.Key, x => x.Value); } Projection = query.Projection; ResultTransformer = query.ResultTransformer; TimeoutValue = query.TimeoutValue; } }
/// <summary> /// Attempts to resolve the <see cref="IProjection" /> representation for the provided /// <see cref="IMorphableFlowQuery" /> instance. /// </summary> /// <param name="query"> /// The <see cref="IMorphableFlowQuery" /> instance. /// </param> /// <returns> /// The resolved <see cref="IProjection" /> representation. /// </returns> protected virtual IProjection GetProjection(IMorphableFlowQuery query) { IProjection queryProjection = query.Projection; var projectionList = queryProjection as ProjectionList; bool isAggregate = query.GroupBys.Count > 0; if (projectionList != null || isAggregate) { var newList = new FqProjectionList(); if (projectionList != null) { for (int i = 0; i < projectionList.Length; i++) { IProjection projection = projectionList[i]; isAggregate = isAggregate || projection.IsAggregate || projection.IsGrouped; } for (int i = 0; i < projectionList.Length; i++) { IProjection projection = projectionList[i]; if (isAggregate) { if (!projection.IsAggregate && !projection.IsGrouped) { var alias = projection as FqAliasProjection; if (alias == null || !(alias.Projection is SubqueryProjection)) { projection = Projections.GroupProperty(projection); } } } newList.Add(projection); } } else { newList.Add(query.Projection); } foreach (FqGroupByProjection projection in query.GroupBys) { newList.Add(projection); } queryProjection = newList; } return(query.IsDistinct ? Projections.Distinct(queryProjection) : queryProjection); }
/// <summary> /// Initializes a new instance of the <see cref="StreamedFlowQuery{TSource}" /> class. /// </summary> /// <param name="criteriaFactory"> /// The criteria factory. /// </param> /// <param name="alias"> /// The alias. /// </param> /// <param name="options"> /// The options. /// </param> /// <param name="query"> /// The query. /// </param> /// <exception cref="System.ArgumentNullException"> /// <paramref name="criteriaFactory" /> is null. /// </exception> protected internal StreamedFlowQuery ( Func <Type, string, ICriteria> criteriaFactory, string alias = null, FlowQueryOptions options = null, IMorphableFlowQuery query = null ) : base(criteriaFactory, alias, options, query) { }
/// <summary> /// Initializes a new instance of the <see cref="ImmediateFlowQueryBase{TSource,TQuery}" /> class. /// </summary> /// <param name="criteriaFactory"> /// The criteria factory. /// </param> /// <param name="alias"> /// The alias. /// </param> /// <param name="options"> /// The options. /// </param> /// <param name="query"> /// The query. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="criteriaFactory" /> is null. /// </exception> protected ImmediateFlowQueryBase ( Func <Type, string, ICriteria> criteriaFactory, string alias = null, FlowQueryOptions options = null, IMorphableFlowQuery query = null ) : base(criteriaFactory, alias, options, query) { }
internal DummyQuery2 ( Func <Type, string, ICriteria> criteriaFactory, string alias = null, FlowQueryOptions options = null, IMorphableFlowQuery query = null ) : base(criteriaFactory, alias, options, query) { }
/// <summary> /// Initializes a new instance of the <see cref="DetachedFlowQuery{TSource}" /> class. /// </summary> /// <param name="criteriaFactory"> /// The criteria factory. /// </param> /// <param name="alias"> /// The alias. /// </param> /// <param name="options"> /// The options. /// </param> /// <param name="query"> /// The query. /// </param> protected internal DetachedFlowQuery ( Func <Type, string, ICriteria> criteriaFactory, string alias = null, FlowQueryOptions options = null, IMorphableFlowQuery query = null ) : base(criteriaFactory, alias, options, query) { if (Constructor != null) { if (Orders.Any(x => !x.IsBasedOnSource)) { var newOrders = OrderHelper.GetSourceBasedOrdersFrom(Orders.ToArray(), Constructor, Data); Orders.Clear(); Orders.AddRange(newOrders); } } }
public override DetachedCriteria Build <TSource>(IMorphableFlowQuery query) { throw new NotImplementedException(); }
/// <summary> /// Builds a <see cref="DetachedCriteria" /> from the given <see cref="IMorphableFlowQuery" /> query. /// </summary> /// <param name="query"> /// The query from which to build a <see cref="ICriteria" />. /// </param> /// <typeparam name="TSource"> /// The <see cref="System.Type" /> of the underlying entity for the given query. /// </typeparam> /// <returns> /// The built <see cref="DetachedCriteria" />. /// </returns> public virtual DetachedCriteria Build <TSource>(IMorphableFlowQuery query) { if (query == null) { throw new ArgumentNullException("query"); } DetachedCriteria criteria = DetachedCriteria.For <TSource>(query.Alias); foreach (Join join in query.Joins) { criteria.CreateAlias(join.Property, join.Alias, join.JoinType, join.WithClause); } foreach (ICriterion criterion in query.Criterions) { criteria.Add(criterion); } foreach (Lock queryLock in query.Locks) { if (queryLock.Alias == null) { criteria.SetLockMode(queryLock.LockMode); } else { criteria.SetLockMode(queryLock.Alias, queryLock.LockMode); } } bool skips = query.ResultsToSkip.HasValue && query.ResultsToSkip.Value > 0; if (skips) { criteria.SetFirstResult(query.ResultsToSkip.Value); } bool takes = query.ResultsToTake.HasValue && query.ResultsToTake.Value > 0; if (takes) { criteria.SetMaxResults(query.ResultsToTake.Value); } if (query.IsCacheable) { criteria.SetCacheable(true); if (query.CacheMode.HasValue) { criteria.SetCacheMode(query.CacheMode.Value); } if (!string.IsNullOrEmpty(query.CacheRegion)) { criteria.SetCacheRegion(query.CacheRegion); } } criteria .SetProjection ( GetProjection(query) ); if (query.ResultTransformer != null) { criteria.SetResultTransformer(query.ResultTransformer); } if (query.Orders.Count > 0 && (skips || takes)) { foreach (OrderByStatement statement in query.Orders) { if (statement.IsBasedOnSource) { criteria.AddOrder(statement.Order); } } } return(criteria); }