本文整理汇总了C#中QueryContext类的典型用法代码示例。如果您正苦于以下问题:C# QueryContext类的具体用法?C# QueryContext怎么用?C# QueryContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryContext类属于命名空间,在下文中一共展示了QueryContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public string Build(string className, QueryContext[] contexts)
{
//_stages = stages;
_contexts = contexts;
_appClassName = className;
//BuildInputOutputValueTypes();
BuildRewrittenTypes();
BuildHeader();
_builder.AppendLine("public class " + _appClassName + " : ServiceMesh");
_builder.BeginBlock();
//BuildConstructor();
BuildServiceClients();
BuildServiceCalls();
foreach (var c in contexts)
BuildQuery(c);
_builder.EndBlock();
BuildFooter();
return _builder.ToString();
}
示例2: Execute
internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
{
if(ChildPredicate!=null)
ChildPredicate.Execute(queryContext, nextPredicate);
queryContext.Tree.Reduce();
CacheEntry entry = null;
decimal sum = 0;
if (queryContext.Tree.LeftList.Count > 0)
{
foreach (string key in queryContext.Tree.LeftList)
{
object attribValue = queryContext.Index.GetAttributeValue(key, AttributeName);
if (attribValue != null)
{
Type type = attribValue.GetType();
if ((type == typeof(bool)) || (type == typeof(DateTime)) || (type == typeof(string)) || (type == typeof(char)))
throw new Exception("SUM can only be applied to integral data types.");
sum += Convert.ToDecimal(attribValue);
}
}
base.SetResult(queryContext, AggregateFunctionType.SUM, Decimal.Round(sum, 4));
}
else
{
base.SetResult(queryContext, AggregateFunctionType.SUM, null);
}
}
示例3: Execute
internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
{
bool sortAscending = true;
bool normalizePredicates = true;
if (Inverse)
sortAscending = false;
SortedList list = new SortedList(new QueryResultComparer(sortAscending));
for (int i = 0; i < members.Count; i++)
{
Predicate predicate = (Predicate)members[i];
bool isOfTypePredicate = predicate is IsOfTypePredicate;
if (isOfTypePredicate)
{
predicate.Execute(queryContext, (Predicate)members[++i]);
normalizePredicates = false;
}
else
{
predicate.ExecuteInternal(queryContext, ref list);
}
}
if (normalizePredicates)
{
if (Inverse)
queryContext.Tree.RightList = GetUnion(list);
else
queryContext.Tree.RightList = GetIntersection(list);
}
}
示例4: Execute
internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
{
if (typename == "*")
throw new ParserException("Incorrect query format. \'*\' is not supported.");
if (queryContext.IndexManager == null)
throw new TypeIndexNotDefined("Index is not defined for '" + typename.ToString() + "'");
queryContext.TypeName = typename;
if (queryContext.Index == null) //try to get virtual index
{
//in case of DisableException is true, exception will not be thrown, and return new attribute index.
if (QueryIndexManager.DisableException)
{
queryContext.Index = new AttributeIndex(null, queryContext.Cache.Context.CacheRoot.Name, null);
return;
}
throw new TypeIndexNotDefined("Index is not defined for '" + typename.ToString() + "'");
}
else
{
//populate the tree for normal queries...
if (nextPredicate == null && queryContext.PopulateTree)
{
queryContext.Tree.Populate(queryContext.Index.GetEnumerator(typename));
}
else
{
nextPredicate.Execute(queryContext, null);
}
}
}
示例5: BuildRdsn
public string BuildRdsn(Type service, QueryContext[] contexts)
{
//_stages = stages;
_contexts = contexts;
_appClassName = service.Name;
//BuildInputOutputValueTypes();
BuildHeaderRdsn(service.Namespace);
BuildRewrittenTypes();
_builder.AppendLine("public class " + _appClassName + "Server_impl :" + _appClassName + "Server");
_builder.BeginBlock();
BuildServiceClientsRdsn();
//thrift or protobuf
BuildServiceCallsRdsn(_appClassName);
foreach (var c in contexts)
//never change
BuildQueryRdsn(c);
//always thrift
BuildServer(_appClassName, ServiceContract.GetServiceCalls(service));
_builder.EndBlock();
BuildMain();
BuildFooter();
return _builder.ToString();
}
示例6: ProcessUpdateEntityReference
private void ProcessUpdateEntityReference(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage, ODataPath odataPath)
{
// This is for change the reference in single-valued navigation property
// PUT ~/Person(0)/Parent/$ref
// {
// "@odata.context": "http://host/service/$metadata#$ref",
// "@odata.id": "Orders(10643)"
// }
if (this.HttpMethod == HttpMethod.PATCH)
{
throw Utility.BuildException(HttpStatusCode.MethodNotAllowed, "PATCH on a reference link is not supported.", null);
}
// Get the parent first
var level = this.QueryContext.QueryPath.Count - 2;
var parent = this.QueryContext.ResolveQuery(this.DataSource, level);
var navigationPropertyName = ((NavigationPropertyLinkSegment)odataPath.LastSegment).NavigationProperty.Name;
using (var messageReader = new ODataMessageReader(requestMessage, this.GetReaderSettings(), this.DataSource.Model))
{
var referenceLink = messageReader.ReadEntityReferenceLink();
var queryContext = new QueryContext(this.ServiceRootUri, referenceLink.Url, this.DataSource.Model);
var target = queryContext.ResolveQuery(this.DataSource);
this.DataSource.UpdateProvider.UpdateLink(parent, navigationPropertyName, target);
this.DataSource.UpdateProvider.SaveChanges();
}
ResponseWriter.WriteEmptyResponse(responseMessage);
}
示例7: CreateWithContext
public static PlusAssignmentOperator CreateWithContext(QueryContext context)
{
return new PlusAssignmentOperator
{
Query = context
};
}
示例8: TreeExpression
/// <summary>
/// Creates a new instance with some parameters.
/// </summary>
/// <param name="child">The child to add.</param>
/// <param name="query">The associated query context.</param>
/// <param name="line">The line where the tree expression starts.</param>
/// <param name="column">The column in the line where the tree exp. starts.</param>
public TreeExpression(ContainerExpression child, QueryContext query, int line, int column)
: base(child)
{
Query = query;
StartColumn = column;
StartLine = line;
}
示例9: SetResult
internal void SetResult(QueryContext queryContext, AggregateFunctionType functionType, object result)
{
QueryResultSet resultSet = new QueryResultSet();
resultSet.Type = QueryType.AggregateFunction;
resultSet.AggregateFunctionType = functionType;
resultSet.AggregateFunctionResult = new DictionaryEntry(functionType, result);
queryContext.ResultSet = resultSet;
}
示例10: BuildExpressionQuery
/// <summary>
/// Builds the ExpressionQuery:
/// - parses Expressions and builds row creator
/// - checks names unicity
/// </summary>
/// <param name="expressions"></param>
/// <param name="queryContext"></param>
/// <returns></returns>
protected virtual ExpressionQuery BuildExpressionQuery(ExpressionChain expressions, QueryContext queryContext)
{
var builderContext = new BuilderContext(queryContext);
BuildExpressionQuery(expressions, builderContext);
CheckTablesAlias(builderContext);
CheckParametersAlias(builderContext);
return builderContext.ExpressionQuery;
}
示例11: Execute
/// <summary>
/// execute to process the query with query context, and save the query at context.Query
/// </summary>
/// <param name="context"></param>
public void Execute(IContext context)
{
var queryContext = context as QueryContext;
if (queryContext == null || queryContext.Querys == null)
return;
var query = new BooleanQuery();
foreach (var q in queryContext.Querys) // process all the queries
{
if (q == null)
continue;
queryContext.CurrentQuery = q;
Lucene.Net.Search.Query curQuery = null;
// recursive process the sub query
if (queryContext.CurrentQuery.Type == QueryType.Operation)
{
var subContext = new QueryContext
{
Querys = q.RelationQuerys,
};
this.Execute(subContext);
curQuery = subContext.Query as Lucene.Net.Search.Query;
}
else // process cur query
{
// get the query attr for build opposite query
var attr = UtilityLib.Reflection.Attribute.GetAttributes<Common.Attributes.BaseAttribute>((q as QueryNode).FieldValue).FirstOrDefault();
if (attr == null)
{
throw new NotImplementedException("field value has no attr for query");
}
attr.Execute(queryContext);
if (queryContext.CurrentQuery.Type == QueryType.QueryField) // 其他的 Query Type 会将检索表达式放到对应的上下文字段
{
curQuery = queryContext.CurrentQuery.Query as Lucene.Net.Search.Query;
}
}
// if curQuery if not null, add it to query with logic
if (curQuery != null)
{
query = this.QueryOperator(
queryContext.CurrentQuery.Logic,
curQuery,
query);
}
}
// save the final query
queryContext.Query = query;
}
示例12: Execute
internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
{
if(ChildPredicate!=null)
ChildPredicate.Execute(queryContext, nextPredicate);
queryContext.Tree.Reduce();
decimal count = queryContext.Tree.LeftList.Count;
base.SetResult(queryContext, AggregateFunctionType.COUNT, count);
}
示例13: ReEvaluate
internal virtual ArrayList ReEvaluate(AttributeIndex index, LocalCacheBase cache, IDictionary attributeValues, string cacheContext)
{
QueryContext context = new QueryContext(cache);
context.AttributeValues = attributeValues;
context.Index = index;
context.CacheContext = cacheContext;
Execute(context, null);
context.Tree.Reduce();
return context.Tree.LeftList;
}
示例14: QueryParts
protected QueryParts(
IServiceProvider locator,
QueryContext context,
IPostgresConverterFactory converterFactory,
IEnumerable<IQuerySimplification> simplifications,
IEnumerable<IExpressionMatcher> expressionMatchers,
IEnumerable<IMemberMatcher> memberMatchers,
IEnumerable<IProjectionMatcher> projectionMatchers)
{
this.Locator = locator;
this.ConverterFactory = converterFactory;
this.Simplifications = new List<IQuerySimplification>(simplifications);
this.ExpressionMatchers = expressionMatchers;
this.MemberMatchers = memberMatchers;
this.ProjectionMatchers = projectionMatchers;
this.Context = context;
}
示例15: Execute
internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
{
if(ChildPredicate!=null)
ChildPredicate.Execute(queryContext, nextPredicate);
queryContext.Tree.Reduce();
CacheEntry entry = null;
IComparable max = null;
bool initialized = false;
Type type = null;
foreach (string key in queryContext.Tree.LeftList)
{
CacheEntry cacheentry = queryContext.Cache.GetEntryInternal(key, false);
IComparable current = (IComparable)queryContext.Index.GetAttributeValue(key, AttributeName, cacheentry.IndexInfo);
if (current != null)
{
type = current.GetType();
if (type == typeof(bool))
throw new Exception("MAX cannot be applied to Boolean data type.");
if (!initialized)
{
max = current;
initialized = true;
}
if (current.CompareTo(max) > 0)
max = current;
}
}
if (type != null)
{
if ((type != typeof(DateTime)) && (type != typeof(string)) && (type != typeof(char)))
{
if (max != null)
{
base.SetResult(queryContext, AggregateFunctionType.MAX, Convert.ToDecimal(max));
return;
}
}
}
base.SetResult(queryContext, AggregateFunctionType.MAX, max);
}