本文整理汇总了C#中Rock.Model.PersonService.GetByFullNameOrdered方法的典型用法代码示例。如果您正苦于以下问题:C# PersonService.GetByFullNameOrdered方法的具体用法?C# PersonService.GetByFullNameOrdered怎么用?C# PersonService.GetByFullNameOrdered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonService
的用法示例。
在下文中一共展示了PersonService.GetByFullNameOrdered方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFamiliesByPersonNameSearch
public IQueryable<FamilySearchResult> GetFamiliesByPersonNameSearch( string searchString, int maxResults = 20 )
{
bool reversed;
RockContext rockContext = new RockContext();
PersonService personService = new PersonService( rockContext );
Guid homeAddressGuid = Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid();
// get list of people matching the search string
IOrderedQueryable<Person> sortedPersonQry = personService
.GetByFullNameOrdered( searchString, true, false, false, out reversed );
var personResults = sortedPersonQry.AsNoTracking().ToList();
List<FamilySearchResult> familyResults = new List<FamilySearchResult>();
foreach ( var person in personResults )
{
var families = personService.GetFamilies( person.Id )
.Select( f => new FamilySearchResult
{
Id = f.Id,
Name = f.Name,
FamilyMembers = f.Members.ToList(),
HomeLocation = f.GroupLocations
.Where( l => l.GroupLocationTypeValue.Guid == homeAddressGuid )
.OrderByDescending( l => l.IsMailingLocation )
.Select( l => l.Location )
.FirstOrDefault(),
MainPhone = f.Members
.OrderBy( m => m.GroupRole.Order )
.ThenBy( m => m.Person.Gender )
.FirstOrDefault()
.Person.PhoneNumbers.OrderBy( p => p.NumberTypeValue.Order ).FirstOrDefault()
} )
.ToList();
foreach ( var family in families )
{
familyResults.Add( family );
}
}
return familyResults.DistinctBy( f => f.Id ).AsQueryable();
}