本文整理汇总了C#中ResultOperatorBase类的典型用法代码示例。如果您正苦于以下问题:C# ResultOperatorBase类的具体用法?C# ResultOperatorBase怎么用?C# ResultOperatorBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResultOperatorBase类属于命名空间,在下文中一共展示了ResultOperatorBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProcessResultOperator
/// <summary>
/// Actually try and process this! The count consisits of a count integer and something to increment it
/// at its current spot.
/// </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)
{
if (gc == null)
throw new ArgumentNullException("CodeEnv must not be null!");
var c = resultOperator as CountResultOperator;
if (c == null)
throw new ArgumentNullException("resultOperator can only be a CountResultOperator and must not be null");
//
// The accumulator where we will store the result.
//
var accumulator = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
accumulator.SetInitialValue("0");
//
// Use the Aggregate infrasturcutre to do the adding. This
// has the advantage that it will correctly combine with
// similar statements during query optimization.
//
var add = Expression.Add(accumulator, Expression.Constant((int)1));
var addResolved = ExpressionToCPP.GetExpression(add, gc, cc, container);
gc.Add(new StatementAggregate(accumulator, addResolved));
return accumulator;
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:36,代码来源:ROCount.cs
示例2: 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!
///
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:69,代码来源:ROTakeSkipOperators.cs
示例3: VisitResultOperator
#pragma warning restore 649
/// <summary>
/// Process a result operator. If this result is amenable to be made into a function, then
/// do so.
/// </summary>
/// <param name="resultOperator"></param>
/// <param name="queryModel"></param>
/// <param name="index"></param>
public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
// Look for a single-result processor
var processor = _operators.FindScalarROProcessor(resultOperator.GetType());
if (processor != null)
{
var result = processor.ProcessResultOperator(resultOperator, queryModel, _codeEnv, _codeContext, MEFContainer);
if (result != null)
{
_codeEnv.SetResult(result);
_scoping.Add(_codeContext.Add(queryModel, result));
}
return;
}
// Look for a sequence processor
var collectionProcessor = _operators.FindCollectionROProcessor(resultOperator.GetType());
if (collectionProcessor != null)
{
collectionProcessor.ProcessResultOperator(resultOperator, queryModel, _codeEnv, _codeContext, MEFContainer);
_codeEnv.ResetResult();
return;
}
///
/// Uh oh - no idea how to do this!
///
throw new InvalidOperationException("LINQToTTree can't translate the operator '" + resultOperator.ToString() + "'");
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:41,代码来源:QueryVisitor.cs
示例4: VisitResultOperator
/// <summary>
/// Visits the result operator.
/// </summary>
/// <param name="resultOperator">The result operator.</param>
/// <param name="queryModel">The query model.</param>
/// <param name="index">The index.</param>
public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
if (resultOperator is CountResultOperator)
{
this.IsCount = true;
}
else
throw new NotSupportedException(string.Format("Operator {0} is not supported.", resultOperator.GetType()));
}
开发者ID:andoco,项目名称:mongodb-csharp,代码行数:15,代码来源:ScalarQueryModelVisitor.cs
示例5: ProcessResultOperator
internal void ProcessResultOperator(
[PexAssumeUnderTest]ROUniqueCombinations target,
ResultOperatorBase resultOperator,
QueryModel queryModel,
CodeContext cc,
[PexAssumeNotNull]GeneratedCode codeEnv
)
{
target.ProcessResultOperator(resultOperator, queryModel, codeEnv, cc, null);
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:10,代码来源:t_ROPairWiseAll.cs
示例6: ProcessIdentityQuery
/// <summary>
/// Try to do a fast count. Basically, what we are dealing with here is the fact that we have
/// a simple array, we need only take its length, and return that.
/// </summary>
/// <param name="resultOperator"></param>
/// <param name="queryModel"></param>
/// <param name="_codeEnv"></param>
/// <param name="_codeContext"></param>
/// <param name="container"></param>
/// <returns></returns>
public Tuple<bool, Expression> ProcessIdentityQuery(ResultOperatorBase resultOperator, QueryModel queryModel, IGeneratedQueryCode _codeEnv, ICodeContext _codeContext, CompositionContainer container)
{
//
// We just need to return a length expression. We are low enough level we need to do some basic resolution.
//
if (!queryModel.MainFromClause.FromExpression.Type.IsArray)
return Tuple.Create(false, null as Expression);
var lengthExpr = Expression.ArrayLength(queryModel.MainFromClause.FromExpression).Resolve(_codeEnv, _codeContext, container);
return Tuple.Create(true, lengthExpr as Expression);
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:22,代码来源:ROCount.cs
示例7: VisitResultOperator
public override void VisitResultOperator (ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
ArgumentUtility.CheckNotNull ("resultOperator", resultOperator);
ArgumentUtility.CheckNotNull ("queryModel", queryModel);
var fetchRequest = resultOperator as FetchRequestBase;
if (fetchRequest != null)
{
queryModel.ResultOperators.RemoveAt (index);
_fetchQueryModelBuilders.Add (new FetchQueryModelBuilder (fetchRequest, queryModel, index));
}
}
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:12,代码来源:FetchFilteringQueryModelVisitor.cs
示例8: VisitResultOperator
public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
if (resultOperator is CountResultOperator)
{
// For count operators, we can remove any order-by result operators
foreach (var orderby in queryModel.BodyClauses.Where(bc => bc is OrderByClause).ToList())
{
queryModel.BodyClauses.Remove(orderby);
}
}
base.VisitResultOperator(resultOperator, queryModel, index);
}
开发者ID:Mrding,项目名称:Ribbon,代码行数:13,代码来源:RemoveUnnecessaryBodyOperators.cs
示例9: ProcessResultOperator
internal Expression ProcessResultOperator(
[PexAssumeUnderTest]ROMinMax target,
ResultOperatorBase resultOperator,
QueryModel queryModel,
IGeneratedQueryCode gc,
ICodeContext cc,
CompositionContainer container
)
{
Expression result
= target.ProcessResultOperator(resultOperator, queryModel, gc, cc, container);
return result;
// TODO: add assertions to method ROMinMaxTest.ProcessResultOperator(ROMinMax, ResultOperatorBase, QueryModel, IGeneratedQueryCode, ICodeContext, CompositionContainer)
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:14,代码来源:ROMinMaxTest.cs
示例10: VisitResultOperator
public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
var handler = resultOperators.GetItem(resultOperator.GetType());
if (handler != null)
{
handler.Accept(resultOperator, model);
}
else
{
model.ApplyUnsupported(resultOperator);
}
base.VisitResultOperator(resultOperator, queryModel, index);
}
开发者ID:dpvreony-forks,项目名称:Lucene.Net.Linq,代码行数:15,代码来源:QueryModelTranslator.cs
示例11: VisitResultOperator
public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
if (resultOperator is FirstResultOperator)
{
_queryParts.Take = 1;
return;
}
if (resultOperator is CountResultOperator || resultOperator is LongCountResultOperator)
{
_queryParts.ReturnCount = true;
return;
}
if (resultOperator is TakeResultOperator)
{
var exp = ((TakeResultOperator)resultOperator).Count;
if (exp.NodeType == ExpressionType.Constant)
{
_queryParts.Take = (int)((ConstantExpression)exp).Value;
}
else
{
throw new NotSupportedException("Currently not supporting methods or variables in the Skip or Take clause.");
}
return;
}
if (resultOperator is SkipResultOperator)
{
var exp = ((SkipResultOperator) resultOperator).Count;
if (exp.NodeType == ExpressionType.Constant)
{
_queryParts.Skip = (int)((ConstantExpression)exp).Value;
}
else
{
throw new NotSupportedException("Currently not supporting methods or variables in the Skip or Take clause.");
}
return;
}
base.VisitResultOperator(resultOperator, queryModel, index);
}
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:48,代码来源:CouchDbApiGeneratorQueryModelVisitor.cs
示例12: ProcessResultOperator
/// <summary>
/// Take the incoming stream of items, and send them along! :-)
/// </summary>
/// <param name="resultOperator"></param>
/// <param name="queryModel"></param>
/// <param name="_codeEnv"></param>
/// <param name="_codeContext"></param>
/// <param name="container"></param>
public void ProcessResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, IGeneratedQueryCode gc, ICodeContext cc, CompositionContainer container)
{
//
// Some basic checks on the input.
//
if (cc == null)
throw new ArgumentNullException("cc");
if (gc == null)
throw new ArgumentNullException("gc");
if (cc.LoopVariable == null)
throw new ArgumentNullException("No defined loop variable!");
//
// Get the indexer that is being used to access things. We will just push that onto a temp vector of int's. That will be
// a list of the items that we want to come back and look at. That said, once done we need to pop-up one level in our
// depth.
//
var arrayRecord = DeclarableParameter.CreateDeclarableParameterArrayExpression(typeof(int));
gc.AddOutsideLoop(arrayRecord);
var recordIndexStatement = new Statements.StatementRecordIndicies(ExpressionToCPP.GetExpression(cc.LoopIndexVariable.AsExpression(), gc, cc, container), arrayRecord);
gc.Add(recordIndexStatement);
gc.Pop();
//
// Now, we go down one loop and run over the pairs with a special loop.
//
var index1 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
var index2 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
var indexIterator = new Statements.StatementPairLoop(arrayRecord, index1, index2);
gc.Add(indexIterator);
//
// Finally, build the resulting loop variable. For now it is just a tuple, which is basically the formed expression we started with,
// but with the other index properties. Other bits will have to do the translation for us. :-)
//
var item1 = cc.LoopVariable.ReplaceSubExpression(cc.LoopIndexVariable.AsExpression(), index1);
var item2 = cc.LoopVariable.ReplaceSubExpression(cc.LoopIndexVariable.AsExpression(), index2);
var tupleType = typeof(Tuple<,>).MakeGenericType(cc.LoopVariable.Type, cc.LoopVariable.Type);
var newTuple = Expression.New(tupleType.GetConstructor(new Type[] { cc.LoopVariable.Type, cc.LoopVariable.Type }), item1, item2);
cc.SetLoopVariable(newTuple, null);
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:56,代码来源:ROUniqueCombinations.cs
示例13: HandleContains
public static List<Expression> HandleContains(ResultOperatorBase resultOperator, IEnumerable values)
{
List<Expression> expressions = new List<Expression>();
if (resultOperator is ContainsResultOperator && values != null)
{
var cro = resultOperator as ContainsResultOperator;
foreach (var v in values)
{
expressions.Add(
Expression.Equal(cro.Item, Expression.Convert(Expression.Constant(v), cro.Item.Type)));
}
}
return expressions;
}
开发者ID:benjaminramey,项目名称:GoodlyFere.Ektron.Linq,代码行数:16,代码来源:IEnumerableMethodHandlers.cs
示例14: HandleResultOperator
public virtual Expression HandleResultOperator(
EntityQueryModelVisitor entityQueryModelVisitor,
ResultOperatorBase resultOperator,
QueryModel queryModel)
{
Check.NotNull(entityQueryModelVisitor, nameof(entityQueryModelVisitor));
Check.NotNull(resultOperator, nameof(resultOperator));
Check.NotNull(queryModel, nameof(queryModel));
ResultHandler handler;
if (!_handlers.TryGetValue(resultOperator.GetType(), out handler))
{
throw new NotImplementedException(resultOperator.GetType().ToString());
}
return handler(entityQueryModelVisitor, resultOperator, queryModel);
}
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:17,代码来源:ResultOperatorHandler.cs
示例15: VisitResultOperator
public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
if (resultOperator is CountResultOperator || resultOperator is LongCountResultOperator)
{
// For count operators, we can remove any order-by result operators
foreach (IBodyClause orderby in queryModel.BodyClauses.Where(bc => bc is OrderByClause).ToList())
{
queryModel.BodyClauses.Remove(orderby);
}
}
if (resultOperator is CastResultOperator)
{
Array.ForEach(queryModel.ResultOperators.OfType<CastResultOperator>().ToArray(), castOperator=> queryModel.ResultOperators.Remove(castOperator));
}
base.VisitResultOperator(resultOperator, queryModel, index);
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:17,代码来源:RemoveUnnecessaryBodyOperators.cs
示例16: ProcessResultOperator
/// <summary>
/// We want to print the results out to a file.
/// </summary>
/// <param name="resultOperator"></param>
/// <param name="queryModel"></param>
/// <param name="_codeEnv"></param>
/// <param name="_codeContext"></param>
/// <param name="container"></param>
/// <returns></returns>
/// <remarks>
/// We can handle several types of streams here:
/// 1) a stream of double's - this is just one column.
/// 2) A stream of Tuples
/// 3) A stream of custom objects
/// </remarks>
public override Expression ProcessResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, IGeneratedQueryCode gc, ICodeContext cc, CompositionContainer container)
{
// Argument checking
var asTTree = resultOperator as AsTTreeResultOperator;
if (asTTree == null)
throw new ArgumentException("resultOperaton");
// Declare the includes.
gc.AddIncludeFile("<map>");
gc.AddIncludeFile("TSystem.h");
gc.AddIncludeFile("TFile.h");
gc.AddIncludeFile("TTree.h");
// If we were left to our own devices generating an output file, then make one up based on the tree name.
var outputFile = asTTree.OutputFile != null
? asTTree.OutputFile
: new FileInfo($"{asTTree.TreeName}.root");
// Declare the TTree and the file we will be using!
// Initialization is not important as we will over-write this directly.
var stream = DeclarableParameter.CreateDeclarableParameterExpression(typeof(OutputTTreeFileType));
stream.InitialValue = new OutputTTreeFileType(outputFile);
// Generate a real filename. We are going to key the file by the cache key. Unfortunately, at this
// point in the generation the cache key isn't known. So we have to have a 'promise' that can be used
// for later when the code is actually generated.
var outputFilePromise = GenerateUniqueFile(outputFile, cc);
// Open the file and declare the tree
gc.AddInitalizationStatement(new StatementSimpleStatement(() => $"{stream.RawValue}.first = new TFile(\"{outputFilePromise().FullName.AddCPPEscapeCharacters()}\",\"RECREATE\")", dependentVars: new string[0], resultVars: new string[] { stream.RawValue }));
gc.AddInitalizationStatement(new StatementSimpleStatement($"{stream.RawValue}.second = new TTree(\"{asTTree.TreeName}\", \"{asTTree.TreeTitle}\")", dependentVars: new string[0], resultVars: new string[] { stream.RawValue }));
// Get the list of item values we are going to need here.
List<Expression> itemValues = ExtractItemValueExpressions(queryModel);
// We are just going to print out the line with the item in it.
var itemAsValues = itemValues.Select(iv => ExpressionToCPP.GetExpression(iv, gc, cc, container)).ToArray();
var pstatement = new StatementFillTree(stream, itemAsValues.Zip(asTTree.HeaderColumns, (i, h) => Tuple.Create(i, h)).ToArray());
gc.Add(pstatement);
// The return is a file path in the C# world. But here in C++, what should be returned?
// We will use a string.
return stream;
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:60,代码来源:ROAsTTree.cs
示例17: VisitResultOperator
public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
//Affects SQL result operators
if (resultOperator is TakeResultOperator)
{
var take = resultOperator as TakeResultOperator;
SqlStatement.Aggregate = string.Format("TOP {0} *", take.Count);
}
else if (resultOperator is AverageResultOperator)
UpdateAggregate(queryModel, "AVG");
else if (resultOperator is CountResultOperator)
SqlStatement.Aggregate = "COUNT(*)";
else if (resultOperator is LongCountResultOperator)
SqlStatement.Aggregate = "COUNT(*)";
else if (resultOperator is FirstResultOperator)
SqlStatement.Aggregate = "TOP 1 *";
else if (resultOperator is MaxResultOperator)
UpdateAggregate(queryModel, "MAX");
else if (resultOperator is MinResultOperator)
UpdateAggregate(queryModel, "MIN");
else if (resultOperator is SumResultOperator)
UpdateAggregate(queryModel, "SUM");
else if (resultOperator is DistinctResultOperator)
ProcessDistinctAggregate(queryModel);
//Not supported result operators
else if (resultOperator is ContainsResultOperator)
throw new NotSupportedException("LinqToExcel does not provide support for the Contains() method");
else if (resultOperator is DefaultIfEmptyResultOperator)
throw new NotSupportedException("LinqToExcel does not provide support for the DefaultIfEmpty() method");
else if (resultOperator is ExceptResultOperator)
throw new NotSupportedException("LinqToExcel does not provide support for the Except() method");
else if (resultOperator is GroupResultOperator)
throw new NotSupportedException("LinqToExcel does not provide support for the Group() method");
else if (resultOperator is IntersectResultOperator)
throw new NotSupportedException("LinqToExcel does not provide support for the Intersect() method");
else if (resultOperator is OfTypeResultOperator)
throw new NotSupportedException("LinqToExcel does not provide support for the OfType() method");
else if (resultOperator is SingleResultOperator)
throw new NotSupportedException("LinqToExcel does not provide support for the Single() method. Use the First() method instead");
else if (resultOperator is UnionResultOperator)
throw new NotSupportedException("LinqToExcel does not provide support for the Union() method");
base.VisitResultOperator(resultOperator, queryModel, index);
}
开发者ID:ouyh18,项目名称:LtePlatform,代码行数:45,代码来源:SqlGeneratorQueryModelVisitor.cs
示例18: VisitResultOperator
public override void VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, int index)
{
base.VisitResultOperator(resultOperator, queryModel, index);
if (resultOperator is FirstResultOperator) {
_objectExpression.Executor.Take(1);
return;
}
var takeResultOperator = resultOperator as TakeResultOperator;
if (takeResultOperator != null) {
var countConstantExpression = takeResultOperator.Count as ConstantExpression;
if (countConstantExpression != null) {
_objectExpression.Take = (int)countConstantExpression.Value;
}
return;
}
var skipResultOperator = resultOperator as SkipResultOperator;
if (skipResultOperator != null) {
var countConstantExpression = skipResultOperator.Count as ConstantExpression;
if (countConstantExpression != null)
_objectExpression.Skip = (int)countConstantExpression.Value;
return;
}
var contains = resultOperator as ContainsResultOperator;
if (contains != null)
{
var visitor = new EnigmaExpressionTreeVisitor(_objectExpression);
visitor.VisitExpression(contains.Item);
_objectExpression.Contains();
return;
}
var any = resultOperator as AnyResultOperator;
if (any != null)
{
_objectExpression.Any();
return;
}
}
开发者ID:jaygumji,项目名称:EnigmaDb,代码行数:44,代码来源:EnigmaQueryModelVisitor.cs
示例19: SetUp
public void SetUp ()
{
_mockRepository = new MockRepository();
_visitorMock = _mockRepository.StrictMock<QueryModelVisitorBase>();
_testVisitor = new TestQueryModelVisitor ();
_bodyClauseMock1 = _mockRepository.StrictMock<WhereClause> (ExpressionHelper.CreateExpression());
_bodyClauseMock2 = _mockRepository.StrictMock<WhereClause> (ExpressionHelper.CreateExpression());
_orderingMock1 = _mockRepository.StrictMock<Ordering> (ExpressionHelper.CreateExpression(), OrderingDirection.Asc);
_orderingMock2 = _mockRepository.StrictMock<Ordering> (ExpressionHelper.CreateExpression(), OrderingDirection.Asc);
_resultOperatorMock1 = _mockRepository.StrictMock<ResultOperatorBase> ();
_resultOperatorMock2 = _mockRepository.StrictMock<ResultOperatorBase> ();
_queryModel = ExpressionHelper.CreateQueryModel<Cook> ();
_orderByClause = ExpressionHelper.CreateOrderByClause ();
_groupJoinClause = ExpressionHelper.CreateGroupJoinClause<Cook> ();
}
开发者ID:hong1990,项目名称:Relinq,代码行数:19,代码来源:QueryModelVisitorBaseTest.cs
示例20: ProcessResultOperator
/// <summary>
/// We want to print the results out to a file.
/// </summary>
/// <param name="resultOperator"></param>
/// <param name="queryModel"></param>
/// <param name="_codeEnv"></param>
/// <param name="_codeContext"></param>
/// <param name="container"></param>
/// <returns></returns>
/// <remarks>
/// We can handle several types of streams here:
/// 1) a stream of double's - this is just one column.
/// 2) A stream of Tuples
/// 3) A stream of custom objects
/// </remarks>
public override Expression ProcessResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, IGeneratedQueryCode gc, ICodeContext cc, CompositionContainer container)
{
// Argument checking
var asCSV = resultOperator as AsCSVResultOperator;
if (asCSV == null)
throw new ArgumentException("resultOperaton");
// Declare the includes.
gc.AddIncludeFile("<fstream>");
gc.AddIncludeFile("<iostream>");
// The output filename. How we do this is a little funny because we need the hash from the completely
// done query, which isn't ready just yet.
var outputFile = GenerateUniqueFile(asCSV.OutputFile, cc);
var stream = DeclarableParameter.CreateDeclarableParameterExpression(typeof(OutputCSVTextFileType));
stream.InitialValue = new OutputCSVTextFileType(outputFile);
var headerline = new StringBuilder();
bool first = true;
foreach (var h in asCSV.HeaderColumns)
{
if (!first)
{
headerline.Append(", ");
}
headerline.Append(h);
first = false;
}
gc.AddInitalizationStatement(new Statements.StatementSimpleStatement($"{stream.RawValue} << \"{headerline.ToString()}\" << std::endl;", dependentVars: new string[0], resultVars: new string[] { stream.RawValue }));
// Get the list of item values we are going to need here.
List<Expression> itemValues = ExtractItemValueExpressions(queryModel);
// We are just going to print out the line with the item in it.
var itemAsValues = itemValues.Select(iv => ExpressionToCPP.GetExpression(iv, gc, cc, container));
var pstatement = new StatementCSVDump(stream, itemAsValues.ToArray());
gc.Add(pstatement);
// The return is a file path in the C# world. But here in C++, what should be returned?
// We will use a string.
return stream;
}
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:57,代码来源:ROAsCSV.cs
注:本文中的ResultOperatorBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论