Any idea what the QueryOver equivalent would be?

--
Mohamed Meligy
Senior Developer, Team Lead Backup (.Net Technologies - TDG - Applications)
Injazat Data Systems
P.O. Box: 8230 Abu Dhabi, UAE.

Phone:  +971 2 6992700
Direct:   +971 2 4045385
Mobile:  +971 50 2623624, +971 55 2017 621

E-mail: [email protected]
Weblog: http://gurustop.net


On Mon, May 3, 2010 at 4:18 AM, Kevin Pang <[email protected]> wrote:

> Nevermind John, your original answer gave me enough information to get
> the query. Here it is, in case anyone else was curious (or if I made a
> mistake and someone wants to correct it):
>
> session.CreateCriteria(typeof (Network))
>        .CreateAlias("Users", "Users")
>        .Add(Expression.Eq("Users.UserId", 42))
>        .List<Network>();
>
> On May 2, 5:11 pm, Kevin Pang <[email protected]> wrote:
> > Here are my Fluent mappings (simplified to only include the necessary
> > pieces):
> >
> >         public class UserMap : ClassMap<User>
> >         {
> >                 public UserMap()
> >                 {
> >                         Table("Users");
> >
> >                         Id(x => x.UserId)
> >                                 .GeneratedBy.Identity();
> >
> >                         HasManyToMany(x => x.Networks)
> >                                 .AsSet()
> >
> .Access.PascalCaseField(Prefix.Underscore)
> >                                 .Table("UserNetworks")
> >                                 .Inverse()
> >                                 .ParentKeyColumn("UserId")
> >                                 .ChildKeyColumn("NetworkId")
> >                                 .Fetch.Select()
> >                                 .AsSet()
> >                                 .Cascade.SaveUpdate();
> >                 }
> >         }
> >
> >         public class NetworkMap : ClassMap<Network>
> >         {
> >                 public NetworkMap()
> >                 {
> >                         Table("Networks");
> >
> >                         Id(x => x.NetworkId)
> >                                 .GeneratedBy.Identity();
> >
> >                         HasManyToMany(x => x.Users)
> >
> .Access.PascalCaseField(Prefix.Underscore)
> >                                 .Table("UserNetworks")
> >                                 .ParentKeyColumn("NetworkId")
> >                                 .ChildKeyColumn("UserId")
> >                                 .Fetch.Select()
> >                                 .AsSet()
> >                                 .Cascade.SaveUpdate();
> >                 }
> >         }
> >
> > On May 2, 3:00 pm, John Davidson <[email protected]> wrote:
> >
> >
> >
> >
> >
> > > If you provide your mappings then I can give you a proper example.
> Without
> > > mappings the idea is to create a criteria to return the Networks object
> and
> > > alias the UserNetworksXref and then select where UserNetworksXref.User
> =
> > > User
> >
> > > John Davidson
> >
> > > On Sun, May 2, 2010 at 4:51 PM, Kevin Pang <[email protected]> wrote:
> > > > I have two tables, Users and Networks, with a many-to-many
> > > > relationship table UserNetworks to indicate which Users are in which
> > > > Networks. I do not have a UserNetwork class to correspond to the
> > > > UserNetworks table.
> >
> > > > How can I construct a query using the Criteria API to retrieve all
> > > > Networks that belong to a User?
> >
> > > > I'm aware that I can simply load up a User first, then traverse over
> > > > its Networks property, but I was wondering how you would do it if you
> > > > wanted to do it via a query instead.
> >
> > > > --
> > > > 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%[email protected]>>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
> >
> > > --
> > > 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 athttp://
> groups.google.com/group/nhusers?hl=en.
> >
> > --
> > 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 athttp://
> groups.google.com/group/nhusers?hl=en.
>
> --
> 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.
>
>

-- 
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