本文整理汇总了C#中Rock.Model.GroupTypeRoleService.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeRoleService.Contains方法的具体用法?C# GroupTypeRoleService.Contains怎么用?C# GroupTypeRoleService.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupTypeRoleService
的用法示例。
在下文中一共展示了GroupTypeRoleService.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExpression
/// <summary>
/// Gets the expression.
/// </summary>
/// <param name="entityType">Type of the entity.</param>
/// <param name="serviceInstance">The service instance.</param>
/// <param name="parameterExpression">The parameter expression.</param>
/// <param name="selection">The selection.</param>
/// <returns></returns>
public override Expression GetExpression( Type entityType, IService serviceInstance, ParameterExpression parameterExpression, string selection )
{
string[] selectionValues = selection.Split( '|' );
if ( selectionValues.Length >= 2 )
{
GroupMemberService groupMemberService = new GroupMemberService( (RockContext)serviceInstance.Context );
List<Guid> groupGuids = selectionValues[0].Split( ',' ).AsGuidList();
var groupService = new GroupService( (RockContext)serviceInstance.Context );
var groupIds = groupService.GetByGuids( groupGuids ).Select( a => a.Id ).Distinct().ToList();
bool includeChildGroups = false;
bool includeChildGroupsIncludeSelected = false;
bool includeChildGroupsPlusDescendants = false;
bool includeInactiveGroups = false;
if ( selectionValues.Length >= 3 )
{
includeChildGroups = selectionValues[2].AsBooleanOrNull() ?? false;
}
if ( selectionValues.Length >= 6 )
{
includeChildGroupsIncludeSelected = selectionValues[4].AsBooleanOrNull() ?? false;
includeChildGroupsPlusDescendants = selectionValues[5].AsBooleanOrNull() ?? false;
}
else if ( includeChildGroups )
{
// in case the selection was saved before these options where added
includeChildGroupsIncludeSelected = true;
includeChildGroupsPlusDescendants = true;
}
if ( selectionValues.Length >= 7 )
{
includeInactiveGroups = selectionValues[6].AsBooleanOrNull() ?? true; ;
}
else
{
// if options where saved before this option was added, set to false, even though it would have included inactive before
includeInactiveGroups = false;
}
GroupMemberStatus? groupMemberStatus = null;
if ( selectionValues.Length >= 4 )
{
groupMemberStatus = selectionValues[3].ConvertToEnumOrNull<GroupMemberStatus>();
}
var groupMemberServiceQry = groupMemberService.Queryable();
if ( includeChildGroups )
{
List<int> childGroupIds = new List<int>();
foreach ( var groupId in groupIds )
{
if ( includeChildGroupsPlusDescendants )
{
// get all children and descendants of the selected group(s)
var descendants = groupService.GetAllDescendents( groupId );
if ( !includeInactiveGroups )
{
descendants = descendants.Where( a => a.IsActive == true );
}
childGroupIds.AddRange( descendants.Select( a => a.Id ).Distinct().ToList() );
}
else
{
// get only immediate children of the selected group(s)
var childGroups = groupService.Queryable().Where( a => a.ParentGroupId == groupId );
if ( !includeInactiveGroups )
{
childGroups = childGroups.Where( a => a.IsActive == true );
}
childGroupIds.AddRange( childGroups.Select( a => a.Id ) );
}
}
if ( includeChildGroupsIncludeSelected )
{
groupMemberServiceQry = groupMemberServiceQry.Where( xx => groupIds.Contains( xx.GroupId ) || childGroupIds.Contains( xx.GroupId ) );
}
else
{
groupMemberServiceQry = groupMemberServiceQry.Where( xx => childGroupIds.Contains( xx.GroupId ) );
}
}
else
{
groupMemberServiceQry = groupMemberServiceQry.Where( xx => groupIds.Contains( xx.GroupId ) );
}
//.........这里部分代码省略.........
示例2: GetExpression
/// <summary>
/// Gets the expression.
/// </summary>
/// <param name="entityType">Type of the entity.</param>
/// <param name="serviceInstance">The service instance.</param>
/// <param name="parameterExpression">The parameter expression.</param>
/// <param name="selection">The selection.</param>
/// <returns></returns>
public override Expression GetExpression( Type entityType, IService serviceInstance, ParameterExpression parameterExpression, string selection )
{
string[] selectionValues = selection.Split( '|' );
if ( selectionValues.Length >= 2 )
{
GroupMemberService groupMemberService = new GroupMemberService( (RockContext)serviceInstance.Context );
int groupTypeId = 0;
Guid groupTypeGuid = selectionValues[0].AsGuid();
var groupType = GroupTypeCache.Read( groupTypeGuid );
if ( groupType != null )
{
groupTypeId = groupType.Id;
}
var groupMemberServiceQry = groupMemberService.Queryable().Where( xx => xx.Group.GroupTypeId == groupTypeId && xx.Group.IsActive == true );
var groupRoleGuids = selectionValues[1].Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ).Select( n => n.AsGuid() ).ToList();
if ( groupRoleGuids.Count() > 0 )
{
var groupRoleIds = new GroupTypeRoleService( (RockContext)serviceInstance.Context ).Queryable().Where( a => groupRoleGuids.Contains( a.Guid ) ).Select( a => a.Id ).ToList();
groupMemberServiceQry = groupMemberServiceQry.Where( xx => groupRoleIds.Contains( xx.GroupRoleId ) );
}
GroupMemberStatus? groupMemberStatus = null;
if ( selectionValues.Length >= 3 )
{
groupMemberStatus = selectionValues[2].ConvertToEnumOrNull<GroupMemberStatus>();
}
if ( groupMemberStatus.HasValue )
{
groupMemberServiceQry = groupMemberServiceQry.Where( xx => xx.GroupMemberStatus == groupMemberStatus.Value );
}
var qry = new PersonService( (RockContext)serviceInstance.Context ).Queryable()
.Where( p => groupMemberServiceQry.Any( xx => xx.PersonId == p.Id ) );
Expression extractedFilterExpression = FilterExpressionExtractor.Extract<Rock.Model.Person>( qry, parameterExpression, "p" );
return extractedFilterExpression;
}
return null;
}
示例3: GetExpression
/// <summary>
/// Gets the expression.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="entityIdProperty">The entity identifier property.</param>
/// <param name="selection">The selection.</param>
/// <returns></returns>
public override Expression GetExpression( RockContext context, MemberExpression entityIdProperty, string selection )
{
var qryGroupService = new GroupService( context ).Queryable();
Expression<Func<Rock.Model.GroupMember, bool>> memberWhereGroupType = a => 1 == 1;
Expression<Func<Rock.Model.GroupMember, bool>> memberWhereGroupRoles = a => 1 == 1;
Expression<Func<Rock.Model.GroupMember, bool>> memberWhereStatus = a => 1 == 1;
string[] selectionValues = selection.Split( '|' );
if ( selectionValues.Length >= 3 )
{
GroupMemberService groupMemberService = new GroupMemberService( context );
int? groupTypeId = null;
Guid groupTypeGuid = selectionValues[1].AsGuid();
var groupType = GroupTypeCache.Read( groupTypeGuid );
if ( groupType != null )
{
groupTypeId = groupType.Id;
}
if ( groupTypeId.HasValue )
{
memberWhereGroupType = xx => xx.Group.GroupTypeId == groupTypeId;
}
var groupRoleGuids = selectionValues[2].Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ).Select( n => n.AsGuid() ).ToList();
List<int> groupRoleIds = null;
if ( groupRoleGuids.Count() > 0 )
{
groupRoleIds = new GroupTypeRoleService( context ).Queryable().Where( a => groupRoleGuids.Contains( a.Guid ) ).Select( a => a.Id ).ToList();
memberWhereGroupRoles = xx => groupRoleIds.Contains( xx.GroupRoleId );
}
GroupMemberStatus? groupMemberStatus = selectionValues[3].ConvertToEnumOrNull<GroupMemberStatus>();
if ( groupMemberStatus.HasValue )
{
memberWhereStatus = xx => xx.GroupMemberStatus == groupMemberStatus.Value;
}
}
var memberListQuery = qryGroupService.Select( p => p.Members.AsQueryable()
.Where( memberWhereGroupType )
.Where( memberWhereGroupRoles )
.Where( memberWhereStatus )
.Select( m => new MemberInfo
{
NickName = m.Person.NickName,
LastName = m.Person.LastName,
SuffixValueId = m.Person.SuffixValueId,
PersonId = m.PersonId,
GroupMemberId = m.Id
} ).OrderBy( a => a.LastName ).ThenBy( a => a.NickName ) );
var selectChildrenExpression = SelectExpressionExtractor.Extract( memberListQuery, entityIdProperty, "p" );
return selectChildrenExpression;
}