|Number of votes:||1|
Recently I had to figure out a way to get all distinct values from a certain attribute in a Relate+ project. The site uses a lot of attributes on IUser to store local copies of attributes in Active Directory. These attributes are then used mainly for presentation, but know they want to filter on these attributes. Filtering on an attribute is quite easy, the issue showed to be getting distinct values for a certain attribute to for example populate a dropdown.
The only solution I found was to use LINQ on a UserCollection. It works great, but the downside might be performance. Because of this, I figured I create a InitializationModule which load all distinct values from the needed attribute and store them in the cache. Then, all I have to do is getting the list from the cache when needed.
There are many good articles on how to create InitializationModules, so I’m going to leave that part out. But here is how I get all distinct values for the attribute “OrganizationAbbreviation”:
Now I can easily populate all my dropdown-lists with the organizational units!