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


C# QueryModel类代码示例

本文整理汇总了C#中QueryModel的典型用法代码示例。如果您正苦于以下问题:C# QueryModel类的具体用法?C# QueryModel怎么用?C# QueryModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QueryModel类属于命名空间,在下文中一共展示了QueryModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Accept

    /// <summary>
    /// Accepts the specified visitor by calling its <see cref="IQueryModelVisitor.VisitMainFromClause"/> method.
    /// </summary>
    /// <param name="visitor">The visitor to accept.</param>
    /// <param name="queryModel">The query model in whose context this clause is visited.</param>
    public virtual void Accept (IQueryModelVisitor visitor, QueryModel queryModel)
    {
      ArgumentUtility.CheckNotNull ("visitor", visitor);
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);

      visitor.VisitMainFromClause (this, queryModel);
    }
开发者ID:hong1990,项目名称:Relinq,代码行数:12,代码来源:MainFromClause.cs

示例2: SetUp

 public void SetUp ()
 {
   _mainFromClause = ExpressionHelper.CreateMainFromClause_Int();
   _selectClause = ExpressionHelper.CreateSelectClause();
   _queryModel = new QueryModel (_mainFromClause, _selectClause);
   _querySourceMapping = new QuerySourceMapping();
 }
开发者ID:hong1990,项目名称:Relinq,代码行数:7,代码来源:QueryModelTest.cs

示例3: GetOrderByClause

 private OrderByClause GetOrderByClause (QueryModel queryModel)
 {
   if (queryModel.BodyClauses.Count == 0)
     return null;
   else
     return queryModel.BodyClauses[queryModel.BodyClauses.Count - 1] as OrderByClause;
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:7,代码来源:ThenByExpressionNode.cs

示例4: NothingShouldGoBang

        public void NothingShouldGoBang()
        {
            var factStore = new MemoryFactStore();
            var aggregateRebuilder = new AggregateRebuilder(factStore);
            var snapshot = new QueryModel<Student>(aggregateRebuilder);
            var eventBroker = Substitute.For<IDomainEventBroker>();

            Guid studentId;

            using (var unitOfWork = new UnitOfWork(factStore, eventBroker, new SystemClock()))
            {
                var repository = new Repository<Student>(snapshot, unitOfWork);

                var student = Student.Create("Fred", "Flintstone");
                studentId = student.Id;
                repository.Add(student);

                unitOfWork.Complete();
            }

            using (var unitOfWork = new UnitOfWork(factStore, eventBroker, new SystemClock()))
            {
                var repository = new Repository<Student>(snapshot, unitOfWork);
                var student = repository.GetById(studentId);

                student.FirstName.ShouldBe("Fred");
                student.LastName.ShouldBe("Flintstone");
            }
        }
开发者ID:uglybugger,项目名称:Sourcerer,代码行数:29,代码来源:WhenCreatingThenRehydratingAnAggregateRoot.cs

示例5: AddSearchItem

 /// <summary>
 /// 将一组key=value添加入QueryModel.Items
 /// </summary>
 /// <param name="model">QueryModel</param>
 /// <param name="key">当前项的HtmlName</param>
 /// <param name="val">当前项的值</param>
 public static void AddSearchItem(QueryModel model, string key, string val)
 {
     string field = "", prefix = "", orGroup = "", method = "";
     var keywords = key.Split(']', ')', '}');
     //将Html中的name分割为我们想要的几个部分
     foreach (var keyword in keywords)
     {
         if (Char.IsLetterOrDigit(keyword[0])) field = keyword;
         var last = keyword.Substring(1);
         if (keyword[0] == '(') prefix = last;
         if (keyword[0] == '[') method = last;
         if (keyword[0] == '{') orGroup = last;
     }
     if (string.IsNullOrEmpty(method)) return;
     if (!string.IsNullOrEmpty(field))
     {
         var item = new ConditionItem
                        {
                            Field = field,
                            Value = val.Trim(),
                            Prefix = prefix,
                            OrGroup = orGroup,
                            Method = (QueryMethod) Enum.Parse(typeof (QueryMethod), method)
                        };
         model.Items.Add(item);
     }
 }
开发者ID:uwitec,项目名称:mb-oa,代码行数:33,代码来源:SearchModelBinder.cs

示例6: Accept

    /// <summary>
    /// Accepts the specified visitor by calling its <see cref="IQueryModelVisitor.VisitWhereClause"/> method.
    /// </summary>
    /// <param name="visitor">The visitor to accept.</param>
    /// <param name="queryModel">The query model in whose context this clause is visited.</param>
    /// <param name="index">The index of this clause in the <paramref name="queryModel"/>'s <see cref="QueryModel.BodyClauses"/> collection.</param>
    public void Accept (IQueryModelVisitor visitor, QueryModel queryModel, int index)
    {
      ArgumentUtility.CheckNotNull ("visitor", visitor);
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);

      visitor.VisitWhereClause (this, queryModel, index);
    }
开发者ID:natemcmaster,项目名称:Relinq,代码行数:13,代码来源:WhereClause.cs

示例7: SetUp

    public void SetUp ()
    {
      _detailSource = ExpressionHelper.CreateQueryable<Kitchen>();
      _sectorSource = ExpressionHelper.CreateQueryable<Restaurant>();

      var query = from s1 in ExpressionHelper.CreateQueryable<Cook>()
                  from sd in
                      (from sector in _sectorSource
                       where sector.ID > 10
                       select sector.SubKitchen)
                  from s2 in s1.Assistants
                  where sd.Name == "Maths"
                  select new NonTransformedTuple<Cook, Kitchen> (s1, sd);
      _queryModel = ExpressionHelper.ParseQuery (query);

      _mainFromClause = _queryModel.MainFromClause;
      _additionalFromClause1 = (AdditionalFromClause) _queryModel.BodyClauses[0];
      _additionalFromClause2 = (AdditionalFromClause) _queryModel.BodyClauses[1];
      _whereClause = (WhereClause) _queryModel.BodyClauses[2];
      _selectClause = _queryModel.SelectClause;

      var subQueryExpressionA = (SubQueryExpression) _additionalFromClause1.FromExpression;
      _innerMainFromClauseA = subQueryExpressionA.QueryModel.MainFromClause;
      _innerWhereClauseA = (WhereClause) subQueryExpressionA.QueryModel.BodyClauses[0];

      _visitor = new SubQueryFromClauseFlattener();
    }
开发者ID:natemcmaster,项目名称:Relinq,代码行数:27,代码来源:SubQueryFromClauseFlattenerTest.cs

示例8: NamedEntity

    public void NamedEntity ()
    {
      // from c in Cooks select c [with name = "inner"]
      var subMainFromClause = new MainFromClause ("c", typeof(Cook), Expression.Constant (Cooks));
      var subSelectClause = new SelectClause (new NamedExpression ("inner", new QuerySourceReferenceExpression (subMainFromClause)));
      var subQuery = new QueryModel (subMainFromClause, subSelectClause);

      // from x in (subQuery) where x.ID == null select x
      var outerMainFromClause = new MainFromClause ("x", typeof(Cook), new SubQueryExpression (subQuery));
      var outerWhereClause = new WhereClause(Expression.Equal(Expression.MakeMemberAccess (new QuerySourceReferenceExpression (outerMainFromClause), typeof (Cook).GetProperty ("ID")), Expression.Constant (1)));
      var outerSelectClause = new SelectClause (new QuerySourceReferenceExpression (outerMainFromClause));
      var outerQuery = new QueryModel (outerMainFromClause, outerSelectClause);
      outerQuery.BodyClauses.Add (outerWhereClause);

      CheckQuery (
          outerQuery, 
          "SELECT [q0].[inner_ID] AS [ID],[q0].[inner_FirstName] AS [FirstName],[q0].[inner_Name] AS [Name],"
          + "[q0].[inner_IsStarredCook] AS [IsStarredCook],[q0].[inner_IsFullTimeCook] AS [IsFullTimeCook],"
          + "[q0].[inner_SubstitutedID] AS [SubstitutedID],[q0].[inner_KitchenID] AS [KitchenID],"
          + "[q0].[inner_KnifeID] AS [KnifeID],[q0].[inner_KnifeClassID] AS [KnifeClassID] " 
          + "FROM (SELECT [t1].[ID] AS [inner_ID],"
          + "[t1].[FirstName] AS [inner_FirstName],[t1].[Name] AS [inner_Name],[t1].[IsStarredCook] AS [inner_IsStarredCook],"
          + "[t1].[IsFullTimeCook] AS [inner_IsFullTimeCook],[t1].[SubstitutedID] AS [inner_SubstitutedID],"
          + "[t1].[KitchenID] AS [inner_KitchenID],[t1].[KnifeID] AS [inner_KnifeID],[t1].[KnifeClassID] AS [inner_KnifeClassID] "
          + "FROM [CookTable] AS [t1]) AS [q0] WHERE ([q0].[inner_ID] = @1)",
          new CommandParameter("@1", 1));
    }
开发者ID:re-motion,项目名称:Relinq-SqlBackend,代码行数:27,代码来源:NamedEntitiesSqlBackendIntegrationTest.cs

示例9: VisitQueryModel

    public void VisitQueryModel ()
    {
      var mainFromClauseMock = _mockRepository.StrictMock<MainFromClause> ("x", typeof (Cook), ExpressionHelper.CreateExpression());
      var selectClauseMock = _mockRepository.StrictMock<SelectClause> (ExpressionHelper.CreateExpression());
      var queryModel = new QueryModel (mainFromClauseMock, selectClauseMock);

      using (_mockRepository.Ordered())
      {
        _visitorMock
            .Expect (mock => mock.VisitQueryModel (queryModel))
            .CallOriginalMethod (OriginalCallOptions.CreateExpectation);
        mainFromClauseMock.Expect (mock => mock.Accept (_visitorMock, queryModel));
        _visitorMock
            .Expect (mock => PrivateInvoke.InvokeNonPublicMethod (mock, "VisitBodyClauses", queryModel.BodyClauses, queryModel));
        selectClauseMock.Expect (mock => mock.Accept (_visitorMock, queryModel));
        _visitorMock
            .Expect (mock => PrivateInvoke.InvokeNonPublicMethod (mock, "VisitResultOperators", queryModel.ResultOperators, queryModel));
      }

      _mockRepository.ReplayAll();

      queryModel.Accept (_visitorMock);

      _mockRepository.VerifyAll();
    }
开发者ID:hong1990,项目名称:Relinq,代码行数:25,代码来源:QueryModelVisitorBaseTest.cs

示例10: SubQueryExpression

    public SubQueryExpression (QueryModel queryModel)
    {
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);

      QueryModel = queryModel;
      _type = queryModel.GetOutputDataInfo().DataType;
    }
开发者ID:hong1990,项目名称:Relinq,代码行数:7,代码来源:SubQueryExpression.cs

示例11: 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);
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:29,代码来源:AggregatingGroupByRewriter.cs

示例12: Accept

    /// <summary>
    /// Accepts the specified visitor by calling its <see cref="IQueryModelVisitor.VisitSelectClause"/> method.
    /// </summary>
    /// <param name="visitor">The visitor to accept.</param>
    /// <param name="queryModel">The query model in whose context this clause is visited.</param>
    public void Accept (IQueryModelVisitor visitor, QueryModel queryModel)
    {
      ArgumentUtility.CheckNotNull ("visitor", visitor);
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);

      visitor.VisitSelectClause (this, queryModel);
    }
开发者ID:natemcmaster,项目名称:Relinq,代码行数:12,代码来源:SelectClause.cs

示例13: VisitOrderByClause

		public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
		{
			foreach (Ordering ordering in orderByClause.Orderings)
			{
				ordering.Expression = JoinReplacer(queryModel, ordering.Expression);
			}
		}
开发者ID:briandonahue,项目名称:nhibernate,代码行数:7,代码来源:AddLeftJoinsReWriter.cs

示例14: Update

 public ActionResult Update([DataSourceRequest] DataSourceRequest request, QueryModel model)
 {
     try
     {
         PopulatePriority();
         PopulateSuppliers();
         PopulateStatus();
         PopulateUsers();
         PopulateCategory();
         if (model!= null && !(model.StatusId > 0))
         ModelState.AddModelError("StatusId","Status field required.");
         
         
         
         
         if (model != null && ModelState.IsValid)
         {
             var user = userService.GetUserProfile(User.Identity.Name);
             if (user == null)
             throw new InvalidCredentialException("User has no permission for this operation");
             model.Query = HttpUtility.HtmlDecode(model.Query);
             model.RaisedById = user.UserId;
             model.Supplier = new SupplierModel() { Id = user.SupplierId };
             service.UpdateQuery(QueryConverter.ConvertBack(model));
             var data = service.GetSupplierQueries(user.SupplierId).Select(QueryConverter.Convert);
             return Json(data.ToDataSourceResult(request));
         }
         
         return Json(ModelState.ToDataSourceResult());
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException(ex.ToString());
     }
 }
开发者ID:maxMint,项目名称:ascendas,代码行数:35,代码来源:ASP.NET+MVC+Controller.cs

示例15: Accept

    /// <summary>
    /// Accepts the specified visitor by calling its <see cref="IQueryModelVisitor.VisitAdditionalFromClause"/> method.
    /// </summary>
    /// <param name="visitor">The visitor to accept.</param>
    /// <param name="queryModel">The query model in whose context this clause is visited.</param>
    /// <param name="index">The index of this clause in the <paramref name="queryModel"/>'s <see cref="QueryModel.BodyClauses"/> collection.</param>
    public virtual void Accept (IQueryModelVisitor visitor, QueryModel queryModel, int index)
    {
      ArgumentUtility.CheckNotNull ("visitor", visitor);
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);

      visitor.VisitAdditionalFromClause (this, queryModel, index);
    }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:13,代码来源:AdditionalFromClause.cs


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