コード例 #1
0
 internal void CopyExpressionTranslation(NhLinqExpression other)
 {
     ExpressionToHqlTranslationResults = other.ExpressionToHqlTranslationResults;
     ParameterDescriptors = other.ParameterDescriptors;
     // Type could have been overridden by translation.
     Type = other.Type;
 }
コード例 #2
0
        protected virtual object ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query)
        {
            // For avoiding breaking derived classes, call the obsolete method until it is dropped.
#pragma warning disable 618
            return(ExecuteQuery(nhLinqExpression, query, nhLinqExpression));

#pragma warning restore 618
        }
コード例 #3
0
        private static void SetupFutureResult(NhLinqExpression nhExpression, IDelayedValue result)
        {
            if (nhExpression.ExpressionToHqlTranslationResults.PostExecuteTransformer == null)
            {
                return;
            }

            result.ExecuteOnEval = nhExpression.ExpressionToHqlTranslationResults.PostExecuteTransformer;
        }
コード例 #4
0
        public virtual void SetResultTransformerAndAdditionalCriteria(IQuery query, NhLinqExpression nhExpression, IDictionary <string, Tuple <object, IType> > parameters)
        {
            if (nhExpression.ExpressionToHqlTranslationResults != null)
            {
                query.SetResultTransformer(nhExpression.ExpressionToHqlTranslationResults.ResultTransformer);

                foreach (var criteria in nhExpression.ExpressionToHqlTranslationResults.AdditionalCriteria)
                {
                    criteria(query, parameters);
                }
            }
        }
コード例 #5
0
        protected virtual NhLinqExpression PrepareQuery(Expression expression, out IQuery query)
        {
            var nhLinqExpression = new NhLinqExpression(expression, Session.Factory);

            if (Collection == null)
            {
                query = Session.CreateQuery(nhLinqExpression);
            }
            else
            {
                query = Session.CreateFilter(Collection, nhLinqExpression);
            }

            SetParameters(query, nhLinqExpression.ParameterValuesByName);
            _options?.Apply(query);
            SetResultTransformerAndAdditionalCriteria(query, nhLinqExpression, nhLinqExpression.ParameterValuesByName);

            return(nhLinqExpression);
        }
コード例 #6
0
        protected virtual object ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery)
        {
            IList results = query.List();

            if (nhQuery.ExpressionToHqlTranslationResults?.PostExecuteTransformer != null)
            {
                try
                {
                    return(nhQuery.ExpressionToHqlTranslationResults.PostExecuteTransformer.DynamicInvoke(results.AsQueryable()));
                }
                catch (TargetInvocationException e)
                {
                    throw ReflectHelper.UnwrapTargetInvocationException(e);
                }
            }

            if (nhLinqExpression.ReturnType == NhLinqExpressionReturnType.Sequence)
            {
                return(results.AsQueryable());
            }

            return(results[0]);
        }
コード例 #7
0
        public virtual object Execute(Expression expression)
        {
            NhLinqExpression nhLinqExpression = PrepareQuery(expression, out var query);

            return(ExecuteQuery(nhLinqExpression, query));
        }
コード例 #8
0
 public IQuery GetPreparedQuery(Expression expression, out NhLinqExpression nhExpression)
 {
     nhExpression = PrepareQuery(expression, out var query);
     return(query);
 }