本文整理汇总了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();
}