Are you suggesting for me to define a sql query in the mappings.

I use fluent nhibernate so dont have any xml mappings.

Can i not acheive this using something like this
IQuery iq = session.CreateSQLQuery("exec myStoredProcedure")
.AddEntity("s", typeof(Shop))
.AddJoin("t", "s.Types");

I have even tried "select {s.*}, {t.*} from Shop s join Shop_Type st
on s.ShopId = st.ShopId join Type t on st.TypeId = t.TypeId"

I get an error Object not Found. I assume that it cannot work out what
t is .

I think that it problably would work if this was a one to many
relationship, i think it gets in trouble with the many to many
relationship.

On Feb 24, 3:21 pm, Fabio Maulo <[email protected]> wrote:
> http://nhforge.org/doc/nh/en/index.html#querysql-load
>
> 2010/2/24 sianabanana <[email protected]>
>
>
>
>
>
> > Sorry Fabio, Im not with you.  what do you mean <loader>
>
> > On Feb 24, 2:56 pm, Fabio Maulo <[email protected]> wrote:
> > > not "CreatSQLQuery" but <loader>
>
> > > 2010/2/22 sianabanana <[email protected]>
>
> > > > I have a stored procedure i would like to run to popoulate my entity.
>
> > > > IQuery iq = session.CreateSQLQuery("exec myStoredProcedure")
> > > > .AddEntity("s", typeof(Shop))
> > > > .AddJoin("t", "s.Types");
>
> > > > var test = iq.List<Shop>();
>
> > > > I have written this stored procedure to get around an N+1 problem with
> > > > Paging.
>
> > > > Shop has a Many to Many relationship with Type.
>
> > > > If i remove the AddJoin and select shop.* from my stored procedure,
> > > > then my shop entity loads up, but obviouly doesnt eager load the
> > > > types.
>
> > > > I think i need to use the AddJoin method to eager load my types but
> > > > cant seem to get it right.
>
> > > > I selected
> > > > ----- shop.*, shopTypes.*, types.*
> > > > ----- shop.*, types.*
>
> > > > but nothing seems to work.
>
> > > > I have even written the hql for this, and then added the selection
> > > > columns from this, but still it doesnt work.
>
> > > > Any ideas???
>
> > > > --
> > > > 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- 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.
>
> --
> Fabio Maulo- 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