Read what it says. The **IResultTransformer** must override Equals.
If you're using an included one (AliasToBean), you're all set.
Diego
On Mon, Aug 9, 2010 at 12:56, MattO <[email protected]> wrote:
> Diego,
>
> I originally got it working with a generic list and getting the RAW
> values. But I have no mapped it to a class by following what was
> described in the nHibernate manual in section (15.1.5. Returning non-
> managed entities).
>
> What has me concern is the following line:
>
> IMPORTANT: The custom IResultTransformer should override Equals and
> GetHashCode, otherwise the query translation won't be cached. This
> also will result in memory leak.
>
> I don't really understand this. Here is my code:
>
> IQuery qry = Session.GetISession().CreateSQLQuery("SELECT
> Row_Number() OVER (ORDER BY ContentCode,ItemNumber,ItemRevisionLevel)
> as RowNumber, RecordID,Row_Number() OVER (ORDER BY
> ContentCode,ItemNumber,ItemRevisionLevel) as Position from
>
> Items").SetResultTransformer(Transformers.AliasToBean(typeof(ExamTypeRecordIDCollection)));
> IList<ExamTypeRecordIDCollection> foo =
> qry.List<ExamTypeRecordIDCollection>();
>
> Here is my class:
>
> public class ExamTypeRecordIDCollection
> {
> public long RowNumber;
> public int RecordID;
> public long Position;
> }
>
> Is the documentation stating I must implement GetHashCode and Equals
> in my non-managed entity class??? WHY?
>
> On Aug 9, 8:59 am, Diego Mijelshon <[email protected]> wrote:
> > You can use ISQLQueries with AddScalar or transformers... checkhttp://
> nhforge.org/doc/nh/en/index.html#querysql-creating
> > <http://nhforge.org/doc/nh/en/index.html#querysql-creating>But you are
> not
> > gonna get much out of NHibernate when using it that way.
> >
> > Diego
> >
> >
> >
> > On Mon, Aug 9, 2010 at 10:06, MattO <[email protected]> wrote:
> > > I'm attempting to convert my data access layer from using primarily
> > > datasets to nHibernate and I've run into a hurdle.
> >
> > > We have many cases where the result set does not map to a business
> > > object such as the following SQL statement:
> >
> > > SELECT Row_Number() OVER (ORDER BY
> > > ContentCode,ItemNumber,ItemRevisionLevel) as RowNumber,
> > > RecordID,Row_Number() OVER (ORDER BY
> > > ContentCode,ItemNumber,ItemRevisionLevel) as Position from Items where
> > > ty...@examtype
> >
> > > It is easy to make a business object for "Item" which is great. But I
> > > have no idea how to tell nHibernate to return the RowNumber and
> > > Position fields in this query.
> >
> > > Also rather then retrieving all 50 fields from my Items table, is it
> > > possible to tell nHibernate to just return the three fields
> > > (RowNumber, RecordID, and Position) as shown in the above query?
> >
> > > How?
> >
> > > --
> > > 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.- 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.
>
>
--
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.