Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:53:58+00:00 2026-06-10T10:53:58+00:00

I’ve asked about how to inject stored procedures support when working with Views in

  • 0

I’ve asked about how to inject stored procedures support when working with Views in SQL Server.

How to use stored procedures in NHibernate for Create/Update when working with database view

Here’s a piece of mapping file:

    <sql-insert>
        exec sp_cycle_insert ?,?,?
    </sql-insert>
    <sql-update>
        exec sp_cycle_update ?,?,?,?,?,?
    </sql-update>
    <sql-delete>
        raiserror ('Cycle can not be deleted', 10, 1)
    </sql-delete>

So, I’ve done the refactoring, etc, and I run my tests…. All failed.

There reason is that SQL Server has view & stored procedures, whereas every time I run a test I set up database from scratch with:

        new SchemaExport(configuration).Execute(false, true, false);

I thought about possible solution and here there are: is there a way to:

  • run additional scripts (I guess that is the solution) with stuff needed by database (like stored procedures, view etc)

On the other hand, running scripts can fail (currently I use sdf files, but what if I change to different provider in the future?). Also procedures/views use WITH construction as well as some SQL Server 2005 functions that can be not supported by database used during testing.

  • . So I though that it’s time to mock repositories. But also here I see obstacles: views compute some readonly properties and NHibernate accesses backing fields using:

access=”nosetter.camelcase”

If I switch to mocking the repository, I would be responsible for implementing view’s logic in code. Are there any other solutions? Or I’m in big trouble!?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:54:00+00:00Added an answer on June 10, 2026 at 10:54 am

    run additional scripts (I guess that is the solution) with stuff needed by database (likestored procedures, view etc)

    Use IAuxiliaryDatabaseObject object(s) for this. It’ll contain extra script to run when creating/dropping your schema using SchemaExport. This/these objects you pass in to your NH Configuration object (AddAuxiliaryDatabaseObject).

    So I though that it’s time to mock repositories. But also here I see obstacles: views compute some readonly properties and NHibernate accesses backing fields using

    You should probably do both. Do integration tests against your real database to verify that your infrastructure/DAL/whatever-you-call-it layer works. In higher layers your probably want to write unit tests instead where things like repositories are mocked.
    If I understand your question correctly you have problems setting up your test state because some data is private on your entities? That’s not really an “issue” caused by NH/repos/data acess, but a general one. There are different ways to solve that, you can; relax your API to make it more testable, have an ctor accepting all data, use reflection one way or the other, let your entity’s interface be readonly but its implementation have setters etc etc etc. It’s hard to give general recommendation but try to find a way that suits your case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.