13

I've been wondering if it's possible to have Fluent-NHibernate communicate with stored procedures that already exist and assign mapping from the result set to my own domain objects.

Also is Fluent-NHibernate able to directly execute procedures with no result set returned?

Basically I've been considering the implications of using Fluent-NHibernate to replace a dated TypedDataSet model with a domain driven design that can return simple objects from the DAL. If Fluent-NHibernate cannot work with SPs easily, I think I would most likley have a combinational DAL that will take advantage of FNH for simple CRUD operations while leaving complex procedures to be managed by Enterprise Library. While I don't think it would be optimal to have 2 competing DALs if FNH cannot play well with SPs I'd love to hear any other ideas than using both EntLib and FNH together.

Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
  • @Gregory I took a look at your blog and honestly i don't know, I've had a falling out with NHibernate/FNH and have kept up anything coming out of them. This seems like it would be a good question to open on stack overflow though. – Chris Marisic May 12 '11 at 13:03

2 Answers2

11

Just to answer my own question, the answer is no other than you can write xml mapppings for NHibernate and combine them with Fluent-NHibernate mappings. SP mapping for FNH will most likely be added later.

Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
6

The trunk version of Fluent NHibernate (on GitHub) supports insert, update and delete stored procedures.

In your mapping class constructor, call:

SqlInsert("StoredProcName");

Disclaimer: I haven't tested this myself yet, but it certainly will come in handy soon.

For more info see this thread in the Fluent NHibernate Google Group.

  • Nice to know of course those are far less useful than the select procedures but I guess that gets into alot more weirder programming. – Chris Marisic Feb 01 '10 at 17:24
  • Yes... the current implementation isn't very useful. In any case for FNH to fully support (*sob*) CRUD stored procedures it still needs to add support for the "loader" and "sql-query" elements. But I don't think there's been any progress there. –  Feb 01 '10 at 19:26