Could you elaborate further on what you want to achieve? Makes it easier to come up with an example. Thanks!
/Kristoffer
I'm also trying to do the same as Claus.
In my case I want to get all users that has an attribute not set to String.Empty and null.
uq["MyAttribute"] != String.Empty && uq["MyAttribute"] != null
I was trying this but it did not do what I want.
UserQuery uq = new UserQuery();
StringCriterion strCriterion = new StringCriterion();
strCriterion.WildCardType= WildCardType.None;
strCriterion.Value = String.Empty;
uq["MyAttribute"] = strCriterion;
UserCollection users = CommunitySystem.CurrentContext.DefaultSecurity.GetQueryResult(uq);
Hi guys,
Try this:
public class NonEmptyStringCriterion : StringCriterion {
public override string GetQuery(string propertyName)
{
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.AppendFormat("NOT ({0} {1} '{2}'", propertyName, EQUALS_OPERATOR, String.Empty);
queryBuilder.AppendFormat(" {0} {1} IS NULL)", OR_OPERATOR, propertyName);
return queryBuilder.ToString();
}
}
Instead of assigning a StringCriterion instance to the uq["MyAttribute"] property, create an instance of NonEmptyStringCriterion and assign it instead. This will find all nonempty attributes.
I am trying to write a query to locate blogs where a specific attribute is empty but I am not sure how to construct the query.
Any suggestions out there?