internal void CopyExpressionTranslation(NhLinqExpression other) { ExpressionToHqlTranslationResults = other.ExpressionToHqlTranslationResults; ParameterDescriptors = other.ParameterDescriptors; // Type could have been overridden by translation. Type = other.Type; }
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 }
private static void SetupFutureResult(NhLinqExpression nhExpression, IDelayedValue result) { if (nhExpression.ExpressionToHqlTranslationResults.PostExecuteTransformer == null) { return; } result.ExecuteOnEval = nhExpression.ExpressionToHqlTranslationResults.PostExecuteTransformer; }
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); } } }
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); }
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]); }
public virtual object Execute(Expression expression) { NhLinqExpression nhLinqExpression = PrepareQuery(expression, out var query); return(ExecuteQuery(nhLinqExpression, query)); }
public IQuery GetPreparedQuery(Expression expression, out NhLinqExpression nhExpression) { nhExpression = PrepareQuery(expression, out var query); return(query); }