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 8461769
In Process

The Archive Base Latest Questions

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

Hey StackOverflow friends, I have a situation where I would like to be able

  • 0

Hey StackOverflow friends,
I have a situation where I would like to be able to cache some nhibernate entites, most likely by means of cached queries. I am trying to figure out the best way to structure this in an MVC 4 project. My NHibernate layer resides in a seperate layer and I am using Windsor for my DI.

I would like to be able to do the following. Say for instance I have a UserTypes table in the database, the PK is a GUID/uniqueidentifier. I want to be able to do a Session.Load(guid) instead of having to pay for the select everytime I need this data.

Here is some code. I don’t like the GUID’s hardcoded like this. I suppose I could stuff the GUIDs in the web.config but I would like something more automatic in case something changes,

nhsession.Save(new User
                           {
                               UserType = nhsession.Load<UserType>(Guid.Parse("BE4A74B1-5B21-4109-AD69-A0AF00FC879F")),
                               UserSetting = nhsession.Load<UserSetting>(Guid.Parse("CB0B2053-E173-408D-A991-A09B00E45330")),
                               UserName = userDto.UserName,
                               Password = hash,
                               Salt = salt,
                               IsLockedOut = 0,
                               InvalidLoginAttempts = 0,
                               ActivationCode = activationCode,
                               Active = active,
                               LastLoginDate = DateTime.Now,
                               DateCreated = DateTime.Now,
                               LastUpdated = DateTime.Now,
                               Profile = new Profile
                                             {
                                                 EmailAddress = userDto.UserName, 
                                                 Active = 1, 
                                                 DateCreated = DateTime.Now, 
                                                 LastUpdated = DateTime.Now
                                             }
                           });
  • 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-10T13:58:09+00:00Added an answer on June 10, 2026 at 1:58 pm

    NHibernate provides support for first and second level caching. The scope of the first level cache is limited to the session itself. However, the second level cache is available to all sessions within the session factory. Ayende Rahien posted a detailed description on NHibernate caching here: http://nhibernate.hibernatingrhinos.com/28/first-and-second-level-caching-in-nhibernate

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

Sidebar

Related Questions

Hey stackoverflow - This is my first question here. I have 2 tables in
Hey StackOverflow community, My question is as follows: I have a table, say USER_ADDR
I would like to have a search box integrated into a nav bar that
Hey guys. Working on Mac OSX 10.6, My problem is that I would like
Hey most of my issue has been solved but i have little problem This
Hey StackOverflow Community, So, I have this line of information from a txt file
Hey all looking throughout all of stackoverflow this looks like a common error i
Hey i have been looking around and i cant find a way to get
*Hey , I have finished developing my app In my iphone apps I have
hey guys having this really simple problem but cant seem to figure out have

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.