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


C# PersonService.SelectMany方法代码示例

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


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

示例1: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var recordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_BUSINESS.AsGuid() ).Id;
            var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
            int? businessRoleId = new GroupTypeRoleService( rockContext ).Queryable()
                .Where( r =>
                    r.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_BUSINESS ) ) )
                .Select( r => r.Id )
                .FirstOrDefault();
            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == recordTypeValueId && q.RecordStatusValueId == activeRecordStatusValueId );

            // Business Name Filter
            var businessName = gfBusinessFilter.GetUserPreference( "Business Name" );
            if ( !string.IsNullOrWhiteSpace( businessName ) )
            {
                queryable = queryable.Where( a => a.FirstName.Contains( businessName ) );
            }

            // Owner Filter
            int ownerId = 0;
            if ( int.TryParse( gfBusinessFilter.GetUserPreference( "Owner" ), out ownerId ) && ownerId != 0 )
            {
                var members = queryable.SelectMany( a => a.Members ).ToList();
                foreach ( var member in members )
                {
                    if ( member.GroupRoleId == businessRoleId )
                    {
                        var groupMemberService = new GroupMemberService( rockContext );
                        var owner = groupMemberService.GetInverseRelationship( member, false, CurrentPersonAlias );
                        if ( owner.PersonId != ownerId )
                        {
                            queryable = queryable.Where( a => a.Id != member.PersonId );
                        }
                    }
                }
            }

            SortProperty sortProperty = gBusinessList.SortProperty;
            if ( sortProperty != null )
            {
                gBusinessList.DataSource = queryable.Sort( sortProperty ).ToList();
            }
            else
            {
                gBusinessList.DataSource = queryable.OrderBy( q => q.FirstName ).ToList();
            }

            gBusinessList.DataBind();
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:54,代码来源:BusinessList.ascx.cs


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