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


C# ISession.Query方法代码示例

本文整理汇总了C#中ISession.Query方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.Query方法的具体用法?C# ISession.Query怎么用?C# ISession.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISession的用法示例。


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

示例1: GetTags

 public static Dictionary<string, Tag> GetTags(ISession session, string[] tagNames)
 {
     if (tagNames.Length < 20) {
         var direct = session.Query<Tag>().Where(t => tagNames.Contains(t.Name)).ToArray();
         return direct.Union(direct.Where(t => t.AliasedTo != null).Select(t => t.AliasedTo)).ToDictionary(t => t.Name, new CaseInsensitiveStringComparer());
     } else {
         return session.Query<Tag>().ToDictionary(t => t.Name);
     }
 }
开发者ID:realzhaorong,项目名称:vocadb,代码行数:9,代码来源:TagHelpers.cs

示例2: PlaceOrderModel

        public PlaceOrderModel(ISession s)
        {
            OrderItemModels = new List<OrderItemModel>();

            var customerReports = s.Query<CustomerReport>().ToList<CustomerReport>();

            var productReports = s.Query<ProductStockReport>()
                .Select(c => new { AggregateRootId = c.AggregateRootId, Name = c.Name + " " + c.Code })
                .ToList();

            Customers = new SelectList(customerReports, "AggregateRootId", "Name");

            Products = new SelectList(productReports, "AggregateRootId", "Name");
        }
开发者ID:ryzam,项目名称:Vaccine-CQRS,代码行数:14,代码来源:PlaceOrderModel.cs

示例3: TestAndAssert

        protected override int TestAndAssert(Expression<Func<MyBO, bool>> condition, ISession session, IEnumerable<int> expectedIds)
        {
            IQueryable<int?> result = session.Query<MyBO>().Where(condition).Select(bo => (int?)bo.BO1.Id);

            var forceDBRun = result.ToList();

            IEnumerable<int> resultNullTo0 = forceDBRun.Select(i => i ?? 0);

            var expectedBO1Ids = session.Query<MyBO>().Where(bo => expectedIds.Contains(bo.Id)).Select(bo => bo.BO1 == null ? 0 : bo.BO1.Id).ToList();
            AreEqual(expectedBO1Ids, resultNullTo0.ToArray());

            // Unused result.
            return -1;
        }
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:14,代码来源:MassTestingMoreOperatorsFixture.cs

示例4: Execute

        public List<RiskAssessmentReviewTask> Execute(Guid employeeId, ISession session)
        {
            try
            {
                //Log.Debug("GetOverdueRiskAssessmentReviewTasks - Execute()");
                var queryableRiskAssessmentsReviews = session.Query<RiskAssessment>()
                    .Where(
                        x =>
                            x.Deleted == false &&
                            (x.Status == RiskAssessmentStatus.Draft || x.Status == RiskAssessmentStatus.Live))
                    .SelectMany(x => x.Reviews)
                    .Where(ReviewTaskIsAssignedToEmployeeOrEmployeeIsTheRiskAssessor(employeeId))
                    .Where(ReviewTasksAreOverdue());

                var riskAssessmentReviewTasks = new List<RiskAssessmentReviewTask>();

                queryableRiskAssessmentsReviews.ForEach(
                    task =>
                    {
                        if (DoesTaskNeedToBeNotified(task, employeeId))
                            riskAssessmentReviewTasks.Add(task.RiskAssessmentReviewTask);
                    });

                return riskAssessmentReviewTasks;
            }
            catch (Exception ex)
            {
                Log.Debug("Exception - GetOverdueRiskAssessmentReviewTasks - Execute()" + ex.Message);
                throw;
            }
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:31,代码来源:GetOverdueRiskAssessmentReviewTasks.cs

示例5: GetGroups

 private static List<Group> GetGroups(ISession session)
 {
     return session.Query<Group>()
         .Cacheable()
         .CacheMode(CacheMode.Normal)
         .ToList();
 }
开发者ID:Nerielle,项目名称:Learning,代码行数:7,代码来源:CacheTests.cs

示例6: Execute

        public List<ActionTask> Execute(Guid employeeId, ISession session)
        {
            try
            {
                //Log.Debug("GetOverdueResponsibilitiesTasksForEmployeeQuery - Execute()" );

                var overdueActionTasks = session
                    .Query<BusinessSafe.Domain.Entities.Action>()
                    .Where(x => x.Deleted == false)
                    .SelectMany(x => x.ActionTasks)
                    .Where(TasksAreAssignedToTheEmployee(employeeId))
                    .Where(TasksAreOverdue());

                var overdueActionTasksTemp = new List<ActionTask>();

                overdueActionTasks.ForEach(
                    task =>
                    {
                        if (DoesTaskNeedToBeNotified(task, employeeId))
                            overdueActionTasksTemp.Add(task);

                    });

                return overdueActionTasksTemp;
            }
            catch (Exception ex)
            {
                Log.Debug("Exception - GetOverdueResponsibilitiesTasksForEmployeeQuery - Execute()" + ex.Message);
                throw;
            }
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:31,代码来源:GetOverdueActionTasksForEmployeeQuery.cs

示例7: Execute

     public List<HazardousSubstanceRiskAssessmentFurtherControlMeasureTask>  Execute(Guid employeeId, ISession session)
        {
            try
            {
                //Log.Debug("GetOverdueHazardousSubstanceRiskAssessmentFurtherControlMeasureTasksForEmployeeQuery - Execute()");
                var queryTasksWhereEmployeeIsRiskAssessor = session.Query<HazardousSubstanceRiskAssessment>()
                    .Where(x => x.Deleted == false // dont return tasks for deleted risk assessments
                                && (x.Status == RiskAssessmentStatus.Draft || x.Status == RiskAssessmentStatus.Live))
                    .SelectMany(x => x.FurtherControlMeasureTasks)
                    .Where(x => x.Deleted == false)
                    .Where(TaskIsAssignedToEmployeeOrEmployeeIsTheRiskAssessor(employeeId))
                    .Where(TasksAreOverdue());

                var hazardousSubstanceRiskAssessmentFurtherControlMeasureTasks =
                    new List<HazardousSubstanceRiskAssessmentFurtherControlMeasureTask>();

                queryTasksWhereEmployeeIsRiskAssessor.ForEach(
                    task =>
                    {
                        if (DoesTaskNeedToBeNotified(task, employeeId))
                            hazardousSubstanceRiskAssessmentFurtherControlMeasureTasks.Add(task);
                    });

                return hazardousSubstanceRiskAssessmentFurtherControlMeasureTasks.ToList();
            }
            catch (Exception ex)
            {
                Log.Debug("Exception - GetOverdueHazardousSubstanceRiskAssessmentFurtherControlMeasureTasksForEmployeeQuery - Execute()" + ex.Message);
                throw;
            }
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:31,代码来源:GetOverdueHazardousSubstanceRiskAssessmentFurtherControlMeasureTask.cs

示例8: Execute

        public List<ActionTask> Execute(Guid employeeId, ISession session)
        {
            try
            {
                //Log.Debug(" GetDueActionTasksForEmployeeQuery - Execute()");

                var overdueActionTasks = session.Query<Domain.Entities.Action>().Where(x => x.Deleted == false)
                    .SelectMany(x => x.ActionTasks)
                    .Where(EmployeeIsTheAssignee(employeeId))
                    .Where(TasksAreDue());

                var actionTasks = new List<ActionTask>();
  
                overdueActionTasks.ForEach(
                    task =>
                    {
                        if (IsTaskDue(task))
                         actionTasks.Add(task);   
                    }); 
                                     
                 return actionTasks;
            }
            catch (Exception ex)
            {
                Log.Debug("Exception - GetDueActionTasksForEmployeeQuery - Execute()" + ex.Message);
                throw;
            }
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:28,代码来源:GetDueActionTasksForEmployeeQuery.cs

示例9: Execute

        public List<RiskAssessmentReviewTask> Execute(Guid employeeId, ISession session)
        {
            try
            {
                //Log.Debug("GetDueRiskAssessmentReviewTasksForEmployeeQuery - Execute()");
                var queryableRiskAssessmentsReviews = session.Query<RiskAssessment>()
                    .Where(
                        x =>
                            x.Deleted == false &&
                            (x.Status == RiskAssessmentStatus.Draft || x.Status == RiskAssessmentStatus.Live))
                    .SelectMany(x => x.Reviews)
                    .Where(ReviewTasksAreDue())
                    .Where(ReviewTaskEmployeeIsAssigneeeOrRiskAssessor(employeeId));

                var riskAssessmentReviewTasks = new List<RiskAssessmentReviewTask>();

                queryableRiskAssessmentsReviews.ForEach(
                    review =>
                    {
                        if (IsTaskDue(review))
                            riskAssessmentReviewTasks.Add(review.RiskAssessmentReviewTask);
                    });

                return riskAssessmentReviewTasks;
            }
            catch (Exception ex)
            {
                Log.Debug("Exception - GetDueRiskAssessmentReviewTasksForEmployeeQuery - Execute()" + ex.Message);
                throw;
            }
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:31,代码来源:GetDueRiskAssessmentReviewTasksForEmployeeQuery.cs

示例10: Execute

        public List<ResponsibilityTask> Execute(Guid employeeId, ISession session)
        {
            try
            {
                //Log.Debug("GetDueResponsibilityTasksForEmployeeQuery - Execute()");
                var queryTasksWhereAssignedToIsEmployee = session.Query<Responsibility>()
                    .Where(r => r.Deleted == false)
                    .SelectMany(r => r.ResponsibilityTasks)
                    .Where(TasksAreDue())
                    .Where(EmployeeIsTheAssignee(employeeId));

                var responsibilityTasks = new List<ResponsibilityTask>();

                queryTasksWhereAssignedToIsEmployee.ForEach(
                    task =>
                    {
                        if (IsTaskDue(task))
                            responsibilityTasks.Add(task);
                    });

                return responsibilityTasks;
            }
            catch (Exception ex)
            {
                Log.Debug("Exception - GetDueResponsibilityTasksForEmployeeQuery - Execute()" + ex.Message);
                throw;
            }
        }
开发者ID:mnasif786,项目名称:Business-Safe,代码行数:28,代码来源:GetDueResponsibilityTasksForEmployeeQuery.cs

示例11: GetWidgetListModel

        private object[] GetWidgetListModel(Guid dashboardId, ISession session)
        {
            var allWidgets = session.Query<Widget>()
                .Where(w => w.Dashboard.Id == dashboardId)
                .ToArray();

            var list = new List<object>();

            foreach (var widget in allWidgets)
            {
                var typeDisplayName = defs.ContainsKey(widget.TypeAlias)
                    ? defs[widget.TypeAlias].DisplayName
                    : string.Format("Unknown ({0})", widget.TypeAlias);

                var model = new
                {
                    id = widget.Id,
                    type = widget.TypeAlias,
                    displayName = widget.DisplayName,
                    sortOrder = widget.SortOrder,
                    typeDisplayName
                };

                list.Add(model);
            }

            return list.ToArray();
        }
开发者ID:hokilpet,项目名称:thinking-home,代码行数:28,代码来源:UniUiPlugin.WidgetList.cs

示例12: ValidarNome

        private void ValidarNome(Usuario usuario, ISession session)
        {
            var qdtUsuariosComMesmoNome = session.Query<Visao>()
                .Count(i => i.Nome.Equals(usuario.UserName) && (i.Id != usuario.Id));

            if (qdtUsuariosComMesmoNome > 0)
                throw new BLLException("Esse username já está sendo usado por outro usuário.");
        }
开发者ID:GabrielMCardozo,项目名称:Sind,代码行数:8,代码来源:ManterUsuario.cs

示例13: RetrievingColumnsByTableId

 public static IEnumerable<ColumnItemResult> RetrievingColumnsByTableId(int tableId, ISession session)
 {
     return session.Query<ColumnEntity>()
         .Where(x => x.ParentTable.Id == tableId)
         .Select(x => new ColumnItemResult { Id = x.Id, ColumnName = x.Name })
         .OrderBy(x => x.ColumnName)
         .ToList();
 }
开发者ID:razed1,项目名称:DatabaseWiki,代码行数:8,代码来源:ColumnQuery.cs

示例14: RetrieveTableInformationByTableId

 public static TableInformationResult RetrieveTableInformationByTableId(int tableId, ISession session)
 {
     return
         session.Query<TableEntity>()
             .Where(x => x.Id == tableId)
             .Select(x => new TableInformationResult { Id = x.Id, DatabaseName = x.DatabaseName, Description = x.Description, SchemaName = x.SchemaName, TableName = x.Name })
             .First();
 }
开发者ID:razed1,项目名称:DatabaseWiki,代码行数:8,代码来源:TableQuery.cs

示例15: NHGetTopSellingAlbums

        private IList<NHAlbum> NHGetTopSellingAlbums(int count)
        {
            _session = MvcApplication.SessionFactory.GetCurrentSession();

            var _query = from a in _session.Query<NHAlbum>()
                         orderby a.OrderDetails.Count
                         select a;
            return _query.Take(5).ToList();
        }
开发者ID:Jiannan,项目名称:NHibernate_MVC_MusicStore,代码行数:9,代码来源:HomeController.cs


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