Always thought that the operation of the stored procedure is not using FN, this time because the back page to statistics, the use of stored procedures, but found in the use of FN currently does not support stored procedures (click to view the official), there is no way, can only use fluent configuration and HBM The mapping method for configuration blending.
Here's what to note:
A) The data returned by the stored procedure, preferably redefining a class, and mapping (can use FN or HDM mode)
b) put the newly defined class and the mapped hbm files on your model layer for easy management later.
c) Map the HDM file name of the stored procedure, named after the name of the return type. (If the returned class is named: DATARESULT,HBM's file name is: DataResult.hbm.xml)
Class
public classTraveldefaultdata{public virtual intUserCount {Get;Set; }public virtual intOrderCount {get; set;} Public Virtual int linecount { get; set;} Public Virtual int crusisecount { get; set;}}
Hbm
<?XmlVersion="1.0"Encoding="Utf-8"?><Hibernate-mappingxmlns="urn:nhibernate-mapping-2.2"Assembly="Travel.domain"Namespace="Bus.travel"> <Sql-queryName="Gettraveldata"> <ReturnClass="Traveldefaultdata"> <Return-propertyColumn="UserCount"Name="UserCount"/> <Return-propertyColumn="OrderCount"Name="OrderCount"/> <Return-propertyColumn="LineCountname=LinCrusiseCount return> EXEC [ Gettraveldata]: userstartdate,: orderstartdate,: linestartdate,: Crusiesstartdate </sql-queryhibernate-mapping >
Traveldefaultdata map, you can refer to here.
Finally, remember to configure the hybrid mapping:
var db = fluentlyareamap> (); A.hbmmappings.addclasses (typeof Traveldefaultdatareturn db. Buildsessionfactory ();
The configuration can then be used in a nhibernate manner.
Fluentnhibernate does not support stored procedures