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

  • Home
  • SEARCH
  • 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 8732945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:32:29+00:00 2026-06-13T09:32:29+00:00

I have a .Net server application backed by a SQL server DB. I’m using

  • 0

I have a .Net server application backed by a SQL server DB. I’m using nHibernate (fluent) to handle all the DB operations. I’m facing serious performance and concurrency issues, obviously deriving from the fact that I’m not an expert (not even close) on nHibernate and ORMs in general.

I have some data that needs to be stored in the DB and some data that doesn’t. For example, I have the members class (which obviously needs to be persisted in the DB) and I also have the logged-in-members class (which only holds runtime data and which doesn’t need to be persisted). Maybe my example is not the best, but I think it demonstrates what my situation is. A logged-in-member object will have a property of type Member so that there is a connection between the two classes.

Is there any way to avoid persisting some classes but still be able to have a complete graph, consisting of both persistent and “in-memory” objects?

  • 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-13T09:32:30+00:00Added an answer on June 13, 2026 at 9:32 am

    I’m not sure how the object graph looks like but why not let the session figure out what changed?

    void DoSomethingWithMembers()
    {
        // if session which loaded the members is not open anymore
        foreach (var member in loggedInMembers.Select(loggedInMember => loggedInMember.Member))
        {
            session.Lock(member, LockMode.None); // reattach to session
        }
        // end if
    
        // make changes to the (loggedIn)members
    
        session.Flush(); // will persist any changes to a member
    }
    

    Update: as response to the comment, something like this

    public AuthenticationResult Authenticate(string username, string password)
    {
        if (loggedInUsers.ContainsKey(username))
            return AuthenticationResult.AlreadyLoggedIn;
    
        using (var session = OpenSession())
        {
            var member = session.Query<Member>().Where(m => m.Name == username).FirstOrDefault();
        }
    
        if (member == null)
            return AuthenticationResult.NoUser;
    
        if (member.Password != password)
            return AuthenticationResult.WrongPassword;
    
        loggedInUsers.Add(username, new LoggedInMember(DateTime.Now, member));
    
        var dto = mapper.Map<Member, MemberDto>(member);
        return new AuthenticationResult(dto);
    }
    
    public void Update(ICollection<MemberDto> dtos)
    {
        using (var session = OpenSession())
        {
            foreach (var dto in dtos)
            {
                Update(session, dto);
            }
            session.Flush();
        }
    }
    
    void Update(ISession session, MemberDto dto)
    {
        LoggedInMember liMember;
        if (!loggedInUsers.TryGetValue(dto.Name, out liMember)
            throw new AuthException("not logged in")
    
        session.Lock(li.Member, LockMode.None); // attach
    
        mapper.Map<Member, MemberDto>(li.Member, dto);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net web application written in C# using a SQL Server 2008
I have an ASP.Net MVC application and I'm using Forms authentication in SQL Server.
My ASP.NET application is using SQL Server 2008 backend. I have a Web Form
I have an asp.net web application backed by SQL Server 2005, and I want
We have developed a .NET web application that uses SQL Server as a backend.
I have an ASP.NET MVC 3 application with a SQL Server 2005 database backend.
I have a SQL Server as backend for an asp.net application. Multiple people might
We have a client running our .NET application which connects to SQL Server 2005
I am developing an asp.net application ,, currently i'm using Sql Server 2008 as
I have a ASP.NET application that connects to a SQL server backend on another

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.