本文整理汇总了C#中Remotion.Linq.QueryModel类的典型用法代码示例。如果您正苦于以下问题:C# QueryModel类的具体用法?C# QueryModel怎么用?C# QueryModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryModel类属于Remotion.Linq命名空间,在下文中一共展示了QueryModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractQueryAnnotations
private static void ExtractQueryAnnotations(
QueryModel queryModel, ICollection<IQueryAnnotation> queryAnnotations)
{
queryModel.MainFromClause
.TransformExpressions(e =>
ExtractQueryAnnotations(e, queryAnnotations));
foreach (var bodyClause in queryModel.BodyClauses)
{
bodyClause
.TransformExpressions(e =>
ExtractQueryAnnotations(e, queryAnnotations));
}
foreach (var resultOperator in queryModel.ResultOperators.ToList())
{
var queryAnnotation = resultOperator as IQueryAnnotation;
if (queryAnnotation != null)
{
queryAnnotations.Add(queryAnnotation);
queryAnnotation.QueryModel = queryModel;
if (queryAnnotation.QuerySource == null)
{
queryAnnotation.QuerySource = queryModel.MainFromClause;
}
queryModel.ResultOperators.Remove(resultOperator);
}
}
}
示例2: VisitOrderByClause
public virtual void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
{
ArgumentUtility.CheckNotNull ("orderByClause", orderByClause);
ArgumentUtility.CheckNotNull ("queryModel", queryModel);
VisitOrderings (orderByClause.Orderings, queryModel, orderByClause);
}
示例3: VisitQueryModel
public override void VisitQueryModel(QueryModel queryModel)
{
queryModel.MainFromClause.Accept(this, queryModel);
VisitBodyClauses(queryModel.BodyClauses, queryModel);
VisitResultOperators(queryModel.ResultOperators, queryModel);
queryModel.SelectClause.Accept(this, queryModel);
}
示例4: VisitAdditionalFromClause
public virtual void VisitAdditionalFromClause(AdditionalFromClause fromClause, QueryModel queryModel, int index)
{
ArgumentUtility.CheckNotNull ("fromClause", fromClause);
ArgumentUtility.CheckNotNull ("queryModel", queryModel);
// nothing to do here
}
示例5: VisitJoinClause
public virtual void VisitJoinClause(JoinClause joinClause, QueryModel queryModel, int index)
{
ArgumentUtility.CheckNotNull ("joinClause", joinClause);
ArgumentUtility.CheckNotNull ("queryModel", queryModel);
// nothing to do here
}
示例6: ExtractQueryAnnotations
private static void ExtractQueryAnnotations(
QueryModel queryModel, ICollection<QueryAnnotationBase> queryAnnotations)
{
foreach (var resultOperator
in queryModel.ResultOperators
.OfType<QueryAnnotationResultOperator>()
.ToList())
{
resultOperator.Annotation.QueryModel = queryModel;
var includeAnnotation = resultOperator.Annotation as IncludeQueryAnnotation;
resultOperator.Annotation.QuerySource = includeAnnotation != null
? ExtractSourceReferenceExpression(includeAnnotation.NavigationPropertyPath).ReferencedQuerySource
: queryModel.MainFromClause;
queryAnnotations.Add(resultOperator.Annotation);
queryModel.ResultOperators.Remove(resultOperator);
}
queryModel.MainFromClause
.TransformExpressions(e =>
ExtractQueryAnnotations(e, queryAnnotations));
foreach (var bodyClause in queryModel.BodyClauses)
{
bodyClause
.TransformExpressions(e =>
ExtractQueryAnnotations(e, queryAnnotations));
}
}
示例7: SimpleArrayContains
public static IWhereFragment SimpleArrayContains(ISerializer serializer, QueryModel queryModel, ContainsResultOperator contains)
{
var from = queryModel.MainFromClause.FromExpression;
var visitor = new FindMembers();
visitor.Visit(from);
var members = visitor.Members;
var constant = contains.Item as ConstantExpression;
if (constant != null)
{
var array = Array.CreateInstance(constant.Type, 1);
array.SetValue(constant.Value, 0);
var dict = new Dictionary<string, object>();
dict.Add(members.Last().Name, array);
members.Reverse().Skip(1).Each(m =>
{
dict = new Dictionary<string, object>() { {m.Name, dict} };
});
return new ContainmentWhereFragment(serializer, dict);
}
throw new NotSupportedException();
}
示例8: ExtractQueryAnnotations
private static void ExtractQueryAnnotations(
QueryModel queryModel, ICollection<QueryAnnotationBase> queryAnnotations)
{
foreach (var resultOperator
in queryModel.ResultOperators
.OfType<QueryAnnotationResultOperator>()
.ToList())
{
resultOperator.Annotation.QueryModel = queryModel;
resultOperator.Annotation.QuerySource = queryModel.MainFromClause;
queryAnnotations.Add(resultOperator.Annotation);
queryModel.ResultOperators.Remove(resultOperator);
}
queryModel.MainFromClause
.TransformExpressions(e =>
ExtractQueryAnnotations(e, queryAnnotations));
foreach (var bodyClause in queryModel.BodyClauses)
{
bodyClause
.TransformExpressions(e =>
ExtractQueryAnnotations(e, queryAnnotations));
}
}
示例9: VisitWhereClause
public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index)
{
WhereJoinDetector.Find(whereClause.Predicate,_nameGenerator,
this,
_joins,
_expressionMap);
}
示例10: ProcessResultOperator
/// <summary>
/// Implement the skipping. We have a main limitation: we currently know only how to implement integer skipping.
/// We implement with "if" statements to support composability, even if it means running longer in the end...
/// We actually return nothing when goes - we aren't really a final result the way "Count" is.
/// </summary>
/// <param name="resultOperator"></param>
/// <param name="queryModel"></param>
/// <param name="_codeEnv"></param>
/// <returns></returns>
public void ProcessResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, IGeneratedQueryCode codeEnv, ICodeContext codeContext, CompositionContainer container)
{
///
/// Quick checks to make sure
///
if (codeEnv == null)
throw new ArgumentNullException("codeEnv cannot be null");
var take = resultOperator as TakeResultOperator;
var skip = resultOperator as SkipResultOperator;
if (take == null && skip == null)
{
throw new ArgumentNullException("resultOperator must not be null and must represent either a take or a skip operation!");
}
if (take != null && take.Count.Type != typeof(int))
throw new ArgumentException("Take operator count must be an integer!");
if (skip != null && skip.Count.Type != typeof(int))
throw new ArgumentException("Skip operator count must be an integer!");
// If this is a "global" take, then we need to declare the variable a bit specially.
// Global: we have a limit on the number of objects that goes across events. We test this by seeing if this
// is a sub-query that is registered (or not).
var isGlobalTake = codeContext.IsInTopLevelQueryModel(queryModel);
// Now, we create a count variable and that is how we will tell if we are still skipping or
// taking. It must be declared in the current block, before our current code! :-)
var counter = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int), otherDependencies: codeContext.LoopIndexVariable.Return<IDeclaredParameter>());
if (isGlobalTake)
{
counter.DeclareAsStatic = true;
codeEnv.Add(counter);
} else
{
codeEnv.AddOutsideLoop(counter);
}
var comparison = StatementIfOnCount.ComparisonOperator.LessThanEqual;
IValue limit = null;
if (skip != null)
{
comparison = StatementIfOnCount.ComparisonOperator.GreaterThan;
limit = ExpressionToCPP.GetExpression(skip.Count, codeEnv, codeContext, container);
}
else
{
limit = ExpressionToCPP.GetExpression(take.Count, codeEnv, codeContext, container);
}
codeEnv.Add(new StatementIfOnCount(counter, limit, comparison));
///
/// We are particularly fortunate here. We don't have to update the Loop variable - whatever it is, is
/// still the right one! Normally we'd have to futz with the LoopVariable in code context because we
/// were iterating over something new. :-) Easy!
///
}
示例11: TransformQueryModel
public static void TransformQueryModel(QueryModel queryModel)
{
var instance = new QueryModelTransformer();
queryModel.Accept(instance);
}
示例12: FlattenSubQuery
protected override void FlattenSubQuery(SubQueryExpression subQueryExpression, FromClauseBase fromClause, QueryModel queryModel,
int destinationIndex)
{
var subQueryModel = subQueryExpression.QueryModel;
MoveResultOperatorsToParent(queryModel, subQueryModel);
base.FlattenSubQuery(subQueryExpression, fromClause, queryModel, destinationIndex);
}
示例13: Generate
public static AdvancedSearchCriteria Generate(QueryModel model, IEktronIdProvider idProvider)
{
TransformationVisitor.Transform(model);
AdvancedSearchCriteria criteria = TranslationVisitor.Translate(model, idProvider);
return criteria;
}
示例14: ApplyNodeSpecificSemantics
protected override QueryModel ApplyNodeSpecificSemantics(QueryModel queryModel,
ClauseGenerationContext clauseGenerationContext)
{
queryModel.BodyClauses.Add(new UseKeysClause(Keys));
return queryModel;
}
示例15: FlattenSubQuery
private void FlattenSubQuery(SubQueryExpression subQueryExpression, FromClauseBase fromClause,
QueryModel queryModel)
{
// Move the result operator up
if (queryModel.ResultOperators.Count != 0)
{
throw new NotImplementedException();
}
var groupBy = (GroupResultOperator) subQueryExpression.QueryModel.ResultOperators[0];
// Replace the outer select clause...
queryModel.SelectClause.TransformExpressions(s => GroupBySelectClauseRewriter.ReWrite(s, groupBy, subQueryExpression.QueryModel));
queryModel.SelectClause.TransformExpressions(
s =>
new SwapQuerySourceVisitor(queryModel.MainFromClause, subQueryExpression.QueryModel.MainFromClause).Swap
(s));
MainFromClause innerMainFromClause = subQueryExpression.QueryModel.MainFromClause;
CopyFromClauseData(innerMainFromClause, fromClause);
foreach (var bodyClause in subQueryExpression.QueryModel.BodyClauses)
{
queryModel.BodyClauses.Add(bodyClause);
}
queryModel.ResultOperators.Add(groupBy);
}