本文整理汇总了C#中Rock.Model.PersonAliasService.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# PersonAliasService.Sort方法的具体用法?C# PersonAliasService.Sort怎么用?C# PersonAliasService.Sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonAliasService
的用法示例。
在下文中一共展示了PersonAliasService.Sort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindGrid
/// <summary>
/// Binds the grid.
/// </summary>
private void BindGrid()
{
if ( CurrentPersonAlias != null )
{
var rockContext = new RockContext();
int personAliasEntityTypeId = EntityTypeCache.Read( "Rock.Model.PersonAlias" ).Id;
var personAliasIds = new FollowingService( new RockContext() ).Queryable()
.Where( f =>
f.EntityTypeId == personAliasEntityTypeId &&
f.PersonAliasId == CurrentPersonAlias.Id )
.Select( f => f.EntityId )
.Distinct()
.ToList();
var qry = new PersonAliasService( rockContext ).Queryable()
.Where( p => personAliasIds.Contains( p.Id ) )
.Select( p => p.Person )
.Distinct();
// Sort
SortProperty sortProperty = gFollowings.SortProperty;
if ( sortProperty == null )
{
sortProperty = new SortProperty( new GridViewSortEventArgs( "LastName,NickName", SortDirection.Ascending ) );
}
Guid homePhoneGuid = Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid();
Guid cellPhoneGuid = Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid();
Guid adultGuid = Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid();
Guid marriedGuid = Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid();
gFollowings.DataSource = qry.Sort( sortProperty )
.Select( p => new
{
p.Id,
p.LastName,
p.NickName,
p.BirthDate,
p.Email,
HomePhone = p.PhoneNumbers
.Where( n => n.NumberTypeValue.Guid.Equals(homePhoneGuid))
.Select( n => n.NumberFormatted)
.FirstOrDefault(),
CellPhone = p.PhoneNumbers
.Where( n => n.NumberTypeValue.Guid.Equals( cellPhoneGuid ) )
.Select( n => n.NumberFormatted )
.FirstOrDefault(),
SpouseName = p.Members
.Where( m =>
p.MaritalStatusValue.Guid.Equals(marriedGuid) &&
m.GroupRole.Guid.Equals(adultGuid))
.SelectMany( m => m.Group.Members)
.Where( m =>
m.PersonId != p.Id &&
m.GroupRole.Guid.Equals(adultGuid) &&
m.Person.MaritalStatusValue.Guid.Equals(marriedGuid) )
.Select( s => s.Person.NickName + " " + s.Person.LastName)
.FirstOrDefault()
} ).ToList();
gFollowings.DataBind();
}
}