当前位置: 首页>>代码示例>>C#>>正文


C# QueryContext类代码示例

本文整理汇总了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();
        }
开发者ID:glglwty,项目名称:rDSN,代码行数:25,代码来源:CodeGenerator.cs

示例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);
            }
        }
开发者ID:christrotter,项目名称:NCache,代码行数:32,代码来源:SumPredicate.cs

示例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);
            }
        }
开发者ID:javithalion,项目名称:NCache,代码行数:34,代码来源:LogicalAndPredicate.cs

示例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);
                }
            }
        }
开发者ID:javithalion,项目名称:NCache,代码行数:35,代码来源:IsOfTypePredicate.cs

示例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();
        }
开发者ID:ykwd,项目名称:rDSN,代码行数:27,代码来源:CodeGenerator.cs

示例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);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:32,代码来源:UpdateHandler.cs

示例7: CreateWithContext

 public static PlusAssignmentOperator CreateWithContext(QueryContext context)
 {
     return new PlusAssignmentOperator
     {
         Query = context
     };
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:7,代码来源:PlusAssignmentOperator.cs

示例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;
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:14,代码来源:TreeExpression.cs

示例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;
 }
开发者ID:javithalion,项目名称:NCache,代码行数:8,代码来源:AggregateFunctionPredicate.cs

示例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;
 }
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:16,代码来源:QueryBuilder.cs

示例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;
        }
开发者ID:sinsay,项目名称:SSE,代码行数:62,代码来源:LuceneQueryProcessor.cs

示例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);
        }
开发者ID:javithalion,项目名称:NCache,代码行数:9,代码来源:CountPredicate.cs

示例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;
        }
开发者ID:javithalion,项目名称:NCache,代码行数:12,代码来源:Predicate.cs

示例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;
 }
开发者ID:ngs-doo,项目名称:revenj,代码行数:17,代码来源:QueryParts.cs

示例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);
        }
开发者ID:javithalion,项目名称:NCache,代码行数:46,代码来源:MaxPredicate.cs


注:本文中的QueryContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。