If the class should be unmapped why you have wrote the mapping ?

2009/6/4 Vels <[email protected]>

>
> Hi..,
>
> i want to update store procedure results to unmapped class (stock)
> Mapping info:
> <class name="Stock">
>    <id (What should be here)</id>
>    <many-to-one name="Item" class="Item" column="ItemCode"
> fetch="join" update="false"/>
>    <property name="ReceiptQty" update="false" />
>    <property name="IssuedQty" update="false" />
>    <property name="BalanceQty" update="false" />
> </class>
>
>  <sql-query name="prcGetItemsStock">
>    <return  class="Stock" alias="Stock">
>      <return-property column="ItemCode" name="Item" />
>      <return-property column="ReceiptQty" name="ReceiptQty" />
>      <return-property column="IssuedQty" name="IssuedQty" />
>      <return-property column="BalanceQty" name="BalanceQty" />
>    </return>
>    exec dbo.prcGetItemsStock
>  </sql-query>
>
> My Store Procedure :
>
> ALTER PROCEDURE [dbo].[prcGetItemsStock]
> AS
> BEGIN
> SELECT ItemCode, SUM(ReceiptQty) AS ReceiptQty, SUM(IssuedQty) AS
> IssuedQty, SUM(ReceiptQty - IssuedQty) AS BalanceQty
> FROM (SELECT ItemCode, ProperQty AS ReceiptQty, 0 AS IssuedQty
>            FROM  tblReceiptDetails
>            UNION ALL
>            SELECT ItemCode, 0 AS ReceiptQty, IssuedQty AS Qty
>            FROM tblIssueDetails) AS dt
> GROUP BY ItemCode
>
> Function RetriveByQuery(Of T)(ByVal Query As String) As List(Of T)
> {
> Dim s As ISession = GetSession(GetType(T))
> Dim iQry As IQuery = s.GetNamedQuery(Query)
> iQry.SetResultTransformer(Transformers.AliasToBean(GetType(T)))
> Return iQry.List(Of T)()
> }
>
> the iQry.List(Of T)() is fetcing the correct number of records but all
> the records are having the same value of the first record
> i.e for first object, it is creating instance and updating the values,
> but for the reset of the objects it is not creating an instance
>
> e.g
> (Query result)
> Property Value
> S1
> S2
> S3
>
> after excuting iQry.List(Of T)()
> S1
> S1
> S1
>
> i referred
>
> http://nhforge.org/blogs/nhibernate/archive/2008/11/24/populating-entities-with-associations-from-stored-procedures-with-nhibernate.aspx
>
> can you help me where i missed ?
>
> NH Version : 2.1.0
> VB.Net 3.5
> SQL 2005
>
> >
>


-- 
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]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to