I have a query where I search for members in a specified range of group names. Works great but... If a user's roles change inside the "real" provider, the query doesn't seem to return the correct results until the user has logged in once more. Is there a job or something that exist that can force changes to be visible inside the data store that the query engine uses?
var cg1 = new CriteriaGroup();
membersQuery.Groups = new GroupCollectionCriterion();
membersQuery.Groups.Containing = new GroupCriterion();
membersQuery.Groups.Containing.Name = new StringCriterion();
membersQuery.Groups.Containing.Name.Includes = new StringInCriterion();
cg1.AddCriterion(membersQuery.Groups);..UserCollection members = QueryHandler.Instance.GetQueryResult<IUser, UserCollection>(membersQuery, ..
Have you tried to throw away cached results and then re-query once more?
I can't think that the roles synch will be involved when removing the cached result for any query? When I'm back working in that project I will give it a quick test run though... Thanks!
Hi Johan,I had a similar problem once where I needed to update forum rights for a user, when the roles had changed inside the "real provider". I fixed it with the following code :
/// Synchronize user roles/groups and invalidate cached entityitems for the user
/// <param name="user">Cloned user object</param>
public static IUser SynchronizeUser(IUser user)
string rolesForUser = Roles.GetRolesForUser(user.UserName);
List<string> list1 = new List<string>(Enumerable.Where<string>((IEnumerable<string>)rolesForUser, (Func<string, bool>)(roleName => Integrator.ShouldTransferRole(roleName))));
List<IGroup> list2 = new List<IGroup>();
foreach (IGroup group in (CacheableCollectionBase<IGroup, GroupCollection>)user.Groups)
if (!list1.Contains(group.Name) && Integrator.ShouldTransferRole(group.Name))
foreach (IGroup group in list2)
foreach (string roleName in list1)
I hope this helps
I'd hoped something was built in but I can work with something like that! Thanks!