本文整理汇总了C#中Remotion.Linq.QueryModel.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# QueryModel.ToString方法的具体用法?C# QueryModel.ToString怎么用?C# QueryModel.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Remotion.Linq.QueryModel
的用法示例。
在下文中一共展示了QueryModel.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitQueryModel
/// <summary>
/// The main driver to parse the query model. We will cache the result into a function
/// if it is something we know how to cache.
/// </summary>
/// <param name="queryModel"></param>
public override void VisitQueryModel(QueryModel queryModel)
{
Debug.WriteLine("VisitQueryModel: {0}{1}", queryModel.ToString(), "");
Debug.Indent();
// If this is a QM function we are referencing, then process it as such.
var qmSource = _codeEnv.FindQMFunction(queryModel);
if (qmSource == null)
{
VisitQueryModelNoCache(queryModel);
}
else
{
VisitQueryModelCache(queryModel, qmSource);
}
Debug.Unindent();
}
示例2: GetReplacement
/// <summary>
/// Get back a query replacement. Null we can't find it.
/// </summary>
/// <param name="queryModel"></param>
/// <returns></returns>
public Expression GetReplacement(QueryModel queryModel)
{
QueryModelCacheLine result = null;
if (_queryModelCache.TryGetValue(queryModel, out result))
{
Debug.WriteLine("Cache Lookup QM Would have returned {0} => {1}", queryModel.ToString(), result.ToString());
Debug.Indent();
foreach (var qs in _queryReplacement)
{
Debug.WriteLine("QS {0} => {1}", qs.Key, qs.Value);
}
Debug.Unindent();
return result._value;
}
return null;
}
示例3: ProcessResultOperator
/// <summary>
/// Process the First/last. This means adding a pointer (or not if we are looking at a plane type) and
/// then filling it till it is full or filling it till the loop is done. Bomb out if we are asked to at the end!!
/// </summary>
/// <param name="resultOperator"></param>
/// <param name="queryModel"></param>
/// <param name="_codeEnv"></param>
/// <returns></returns>
public Expression ProcessResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel,
IGeneratedQueryCode gc, ICodeContext cc, CompositionContainer container)
{
///
/// First, do data normalization
///
var asFirst = resultOperator as FirstResultOperator;
var asLast = resultOperator as LastResultOperator;
if (asFirst == null && asLast == null)
{
throw new ArgumentNullException("First/Last operator must be either first or last, and not null!");
}
bool isFirst = asFirst != null;
bool bombIfNothing = true;
if (isFirst)
{
bombIfNothing = !asFirst.ReturnDefaultWhenEmpty;
}
else
{
bombIfNothing = !asLast.ReturnDefaultWhenEmpty;
}
//
// Figure out if we need to cache the result:
// - simple variable which has a default value which can be used later on.
// like a double, etc.
// - We actually allow for a default variable.
//
bool cacheResult = cc.LoopVariable.Type.IsNumberType();
cacheResult = cacheResult && !bombIfNothing;
//
// Next, make sure we are looping over something. This had better be an array we are looking at!
//
if (cc.LoopIndexVariable == null)
{
throw new InvalidOperationException(string.Format("Can't apply First operator when we aren't looping over some well formed array '{0}'", cc.LoopVariable.ToString()));
}
var indexExpr = cc.LoopIndexVariable;
//
// We need to hold onto either the first or the last item here, so we create a statement that holds nnto the
// first or the last time. It also has to mark the thing as valid! It will break when it is done.
// While the bool can be used later on to get at the exception we might be throwing, the actual
// result may be used much further on down. To protect against that, we set the array index to be -1,
// and then hope there is a crash later on! :-)
//
// It is possible that this is part of a dual selection. For example, if you are interested in the jet that has the closest track, and the
// loop is constructed over the jets first, and then the tracks. This First will likely be for a track index, but we will be looking up the
// track later. So we need to record both the jet and track index. To get the other indicies, we just look for all loop variables between here and
// the result scope.
//
var valueWasSeen = DeclarableParameter.CreateDeclarableParameterExpression(typeof(bool));
var indexSeen = DeclarableParameter.CreateDeclarableParameterExpression(indexExpr.Type);
if (indexSeen.Type.IsNumberType())
indexSeen.SetInitialValue("-1");
gc.AddAtResultScope(valueWasSeen);
gc.AddAtResultScope(indexSeen);
var rv = new Statements.StatementRecordValue(indexSeen, indexExpr, valueWasSeen, isFirst);
gc.Add(rv);
foreach (var v in gc.GetUsedQuerySourceVariables(rv, indexExpr))
{
var saver = DeclarableParameter.CreateDeclarableParameterExpression(v.Type);
gc.AddAtResultScope(saver);
rv.AddNewSaver(saver, v);
cc.Add(v.RawValue, saver);
}
gc.Pop(true);
if (bombIfNothing)
{
var test = ExpressionToCPP.GetExpression(Expression.Not(valueWasSeen), gc, cc, container);
gc.Add(new Statements.StatementThrowIfTrue(test, string.Format("First/Last predicate executed on a null sequence: {0}", queryModel.ToString())));
}
//
// Finally, we need the new expression. For this we basically just ask for the translated expression. We
// also add a substitution for later on for more complex expressions.
//
var firstlastValue = cc.LoopVariable;
//.........这里部分代码省略.........