@Olivier - you know what, that worked!  I must have been trying to fit
it into the WithTable call that day, sorry! :)  Thanks for your help!

On Mar 8, 3:18 pm, Olivier Coanet <[email protected]> wrote:
> Well, I tried, WithTableName("(select distinct UserId, ClientId from
> V_UserClients)" is working just fine.
>
>
>
> On Mon, Mar 8, 2010 at 4:44 PM, Colin Bowern <[email protected]> wrote:
> > So I looked into both and cannot figure out how to apply either given
> > that the AccessControlEntry component is only a part of a larger
> > object. Let me share the rest of the User map that might help as to
> > why it isn't a straight forward criteria:
>
> > WithTable("Users");
> > Id(x => x.Id, "UserId");
> > Map(x => x.Name, "UserName");
> > HasMany<long>(x => x.Clients)
> >    .WithTableName("V_UserClients")
> >    .KeyColumnNames.Add("UserId")
> >    .AsElement("ClientId");
> > ...
>
> > How can I query for user with the ID 1234 and tell it only to grab
> > distinct rights entries?
>
> > On Mar 6, 10:40 am, Colin Bowern <[email protected]> wrote:
> > > @Olivier, @Fabio - thanks.  I will give each of those a try (hacking
> > > the table name, vs. doing it at query time).
>
> > > On Mar 6, 7:51 am, Olivier Coanet <[email protected]> wrote:
>
> > > > Colin,
>
> > > > If performance is not your main concern, you can use the following hack
> > :
> > > > WithTableName("(select distinct * from V_UserApplicationPermissions)")
>
> > > > On Sat, Mar 6, 2010 at 3:57 AM, Fabio Maulo <[email protected]>
> > wrote:
> > > > > select distinct u from User u where u.Id = :thisIsAbergamotta
>
> > > > > 2010/3/5 Colin Bowern <[email protected]>
>
> > > > > I have an existing view which has too much data in it. Unfortunately
> > I
> > > > >> cannot get rid of it so I need to try to work around it using my
> > > > >> NHibernate mapping. The idea is to have NH issue the following
> > query:
>
> > > > >> SELECT DISTINCT User_Id, Module_Id, Application_Id, RightsMask
> > > > >> FROM V_UserApplicationPermissions
> > > > >> WHERE User_Id = ?
>
> > > > >> My current mapping for this list of AccessControlEntry types looks
> > > > >> like this:
>
> > > > >> HasMany<AccessControlEntry>(x => x.Rights)
> > > > >>    .WithTableName("V_UserApplicationPermissions")
> > > > >>    .KeyColumnNames.Add("User_Id")
> > > > >>    .Component(c =>
> > > > >>    {
> > > > >>        c.Map(x => x.Module, "Module_Id");
> > > > >>        c.Map(x => x.Application, "App_Id");
> > > > >>        c.Map(x => x.Rights,
> > > > >> "RightsMask").CustomTypeIs<ApplicationRightsType>();
> > > > >>    })
> > > > >>    .Not.LazyLoad();
>
> > > > >> Any thoughts on how to have NHibernate put a DISTINCT keyword in
> > there
> > > > >> during the query?
>
> > > > >> --
> > > > >> You received this message because you are subscribed to the Google
> > Groups
> > > > >> "nhusers" group.
> > > > >> To post to this group, send email to [email protected].
> > > > >> To unsubscribe from this group, send email to
> > > > >> [email protected]<nhusers%[email protected]­>
> > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup­s.com>
> > ­­>
> > > > >> .
> > > > >> For more options, visit this group at
> > > > >>http://groups.google.com/group/nhusers?hl=en.
>
> > > > > --
> > > > > Fabio Maulo
>
> > > > >  --
> > > > > You received this message because you are subscribed to the Google
> > Groups
> > > > > "nhusers" group.
> > > > > To post to this group, send email to [email protected].
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<nhusers%[email protected]­>
> > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup­s.com>
> > ­­>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/nhusers?hl=en.-Hidequoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]­>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to