Hi

I'm trying to get a list of unmanaged entities through calling an SP
through NHibernate.

from 15.1.5. Returning non-managed entities in the docs - I should
just be able to:

<code>

sess.CreateSQLQuery("SELECT NAME, BIRTHDATE FROM CATS")
        .SetResultTransformer(Transformers.AliasToBean(typeof(CatDTO)))

</code>

here's the actual code I'm trying to get working - this is a minimal
complexity example:

<code>

 string sql =
               "SELECT CurrentMonthBudget, Commitment FROM dbo.Balance";
            IList<BudgetManager> x = Session.Session
                .CreateSQLQuery(sql)

.SetResultTransformer(Transformers.AliasToBean(typeof(BudgetManager))).List<BudgetManager>();

</code>

which doesn't even nearly work :(

After doing some reading/googling I managed to find that I might
supposed to be doing this:

<code>

 string sql =
               "SELECT CurrentMonthBudget, Commitment FROM dbo.Balance";
            IList<BudgetManager> x = Session.Session
                .CreateSQLQuery(sql)
                .AddScalar("CurrentMonthBudget",
NHibernate.NHibernateUtil.Decimal)
                .AddScalar("Commitment", NHibernate.NHibernateUtil.Decimal)

.SetResultTransformer(Transformers.AliasToBean(typeof(BudgetManager))).List<BudgetManager>();

</code>

Is the AddScalar necessary for every return column?

The names on my entity are the same as the column names being returned
- it kinda hints from the example in the docs that this is all infered
and AddScalar is only needed if the names are different.



Cheers,

w://

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