I watched your video and it was a pretty complete review of how Queries work in the CMS. However, it wasn't too helpful for coding custom queries.
I searched through all the IFilterProvider implementations and it gave me some good ideas. However, I wasn't certain how the Role portion would work with the content portion so, I decided to go a different direction.
Instead, I've created an entry on the Admin menu and I'm leveraging Orchard.Users quite a bit. However, the Role portion is
biting me in the behind.
Here's a snippet of what I've been trying:
var users = Services.ContentManager.Query<UserPart, UserPartRecord>().Where(u => (userRolesRepository.Fetch(x => x.UserId == u.Id).Any(r => r.Role.Name == "MyRole")));
I wasn't too excited to use IRepository, but I went through Orchard.Roles and it looks like that's the only way to get it.
It compiles but dies with a:
NHibernate.QueryException: could not resolve property: x of: Orchard.Users.Models.UserPartRecord at NHibernate.Persister.Entity.AbstractPropertyMapping.ToType(String propertyName) ..... (plus a good 30 lines more of dump)
I'm confused since "x" is part of the Fetch from the userRolesRepository, not UserPartRecord. Now, I'm pretty sure I'm running up against my own inexperience with NHibernate and Linq. However, if that's
the way to do it, what is? I've found quite a few posts of folks with similar questions trying to get the Role of a given user, but no-one seems to have a good way of doing it.
Anyone have any good tips?