Fluentnhibernate does not support stored procedures

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.