Hello,
I am using NHibernate1.2 and SQL Server, and have a problem with executing SP's.
Class Person
{
Guid PersonUID;
string LastName;
string FirstName;
Guid AddressUID
}
Class Address
{
Guid AddressUid;
string Address1;
string City;
string State;
}
Now I create a SP as
CREATE PROCEDURE [dbo].[pr_GetPersonDetails]
@PersonUID uniqueidentifier
AS
SET NOCOUNT ON
SELECT PersonUID ,LastName,Add.City FROM Person Per
INNER JOIN Address Add ON Add.AddressUID=Per.AddressUID WHERE
PersonUID =@PersonUID
GO
Now I add this to register pr_GetPersonDetails
<sql-query name="pr_GetPersonDetails">
<return alias="Per" class="NHibernateTest.Person,NHibernateTest">
<return-property name="PersonUID" column="PersonUID"></return-property>
<return-property name="LastName" column="LastName"></return-property>
<return-property name="City" column="City"></return-property>
</return>
exec pr_GetPersonDetails ?
</sql-query>
My Question is Do I need to collect the result set returned by the stored procedure in a class that matches the result set defination.
Meaning If my SP returns all columns from Person table and I collect the result set in Type Person it works. But if I execute the above mentioned SP I get an ADO Exception.
If my SP returns PersonUID ,LastName,City,
Then do I need to have a class defined with these 3 columns(properites), as say PersonDetails?
In the above case I can replace the SP with a view , but we have a lot complicated SP which can't be replaced by views.
Please advise.
|