Skip to content

Instantly share code, notes, and snippets.

@derans
Created August 25, 2012 07:31
Show Gist options
  • Save derans/3462086 to your computer and use it in GitHub Desktop.
Save derans/3462086 to your computer and use it in GitHub Desktop.
ISelectListProvider implementation example
public class CommunitySelectListProvider : ISelectListProvider
{
private readonly IGetCommunitiesQuery _getCommunitiesQuery;
public CommunitySelectListProvider(IGetCommunitiesQuery getCommunitiesQuery)
{
_getCommunitiesQuery = getCommunitiesQuery;
}
public IEnumerable<SelectListItem> Provide()
{
var communities = _getCommunitiesQuery.Execute();
return communities.Select(community => new SelectListItem { Text = community.Name, Value = community.CommunityId.ToString() }).ToList();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment