Tips and Tricks in a world of Mix

    1. Gave the mapping file the extension .hbm.xml
    2. Set the build action to ‘Embedded Resource’
    3. Set the copy-to-output to ‘Copy Always’
    4. Created the Hbm for SP:

<?xml version=1.0encoding=utf-8?>
<
hibernate-mapping xmlns=urn:nhibernate-mapping-2.2assembly=Infranamespace=Infra.Entities>
<sql-query name=GETMYDATA>
<
return class=Kav>
<
return-property column=Kav.MAKAT8name=MAKAT8/>
<
return-property column=Kav.DESCRIPTIONname=DESCRIPTION/>
</
return>
exec  GETMYDATA  :P_PARAM1 , :P_PARAM2 , :MY_CURSOR
</sql-query>

</hibernate-mapping>

5. Created the Entity class :

using System;

namespace Infra.Entities
{
[Serializable]
public class Kav : Entity
{
public virtual string Makat8 { get; set; }
public virtual string Description { get; set; }
}
}

6. Created the Mapping class for the entity:

namespace Infra.Entities.Mapping
{
public class KavMapping : EntityClassMap<Kav>
{
public KavMapping()
{
Table(“kav_tkufa”);
ReadOnly();
Id(x => x.Makat8).Column(“MAKAT8”).Length(10);
Map(x => x.Description).Column(“Description”).Length(50);

}
}
}

7. Added the mapping to the FNH configuration (the entities and hbm in the same assembly) :

.Mappings(m =>
{
m.FluentMappings.AddFromAssemblyOf<KavMapping>();
m.HbmMappings.AddFromAssemblyOf<KavMapping>();
m.MergeMappings();
} )

I’ve read Ayende’s post http://ayende.com/blog/1692/using-nhibernate-with-stored-procedures on connecting to SP , but I’m failing to connect.

How should I map the Kav so that I could get the list of entities from SP ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: