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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:25:58+00:00 2026-06-08T21:25:58+00:00

In my application there are many cases where I have to update one single

  • 0

In my application there are many cases where I have to update one single property of an entity in the database. In the internet I’ve read that DynamicUpdate() should change the behaviour of Fluent NHibernate so it does only update the properties != null

So I wrote my mapping like this:

public class Building
{
    public virtual Guid Id { get; set; }

    public virtual int ConstructionPhase { get; set; }

    public virtual string Name { get; set; }

    [some other properties]
}

public class BuildingMap : ClassMap<Building>, IMappedEntity
    {
        public BuildingMap()
        {
            DynamicUpdate();
            SelectBeforeUpdate();

            Id(x => x.Id);
            Map(x => x.ConstructionPhase);
            Map(x => x.Name);
            [some other properties]
        }
    }

But if I try to update an entity and leave the name property empty, the name is deleted in the database.

Do I have to configure Fluent NHibernate in an other way, or what’s the problem?

  • 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-08T21:26:00+00:00Added an answer on June 8, 2026 at 9:26 pm

    DynamicUpdate() will instruct NHibernate to only save properties that have changed so loading the object, changing a single property and Flushing the session will only update the column that has changed.

    Update: to update single properties without going to the database use hql

    var affectedRows = session.CreateQuery("UPDATE MyEntity SET SomeProperty=:newValue WHERE Id=:id")
        .SetParameter("newValue", value)
        .SetParameter("id", id)
        .ExecuteUpdate();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an application that read how many files are there in a
I have started using ajax/jQuery in our websites / application. There are many plugins
I have an application with many different parts, it runs on OSGi, so there's
I have an internal application in which one function is containing too many switch
We have common views that we use in our application in many locations inside
I have an application that consists of two processes, one client process with a
There are many places in my application where I need to generate links with
I am developing a P2P streaming application. There are many library for playing multimedia
I am working on an application with many html pages. I have created these
In my Java application there is a Socket open and data is being read

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.