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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:09:51+00:00 2026-05-27T18:09:51+00:00

In a few cases, I have a property that needs a backing property for

  • 0

In a few cases, I have a property that needs a “backing property” for practical reasons.

For example, I have one type with a Name property – there is no transformation of the value happening on access, it merely triggers an action of some kind; a side-effect, if you will. (not that it matters for the sake of discussion, but in this particular case, the name gets copied somewhere else when changed.)

Let’s say:

public class Person
{
    private string __name;

    protected internal virtual string _name
    {
        get
        {
            return this.__name;
        }
        set
        {
            this.__name = value;
        }
    }

    public virtual string Name
    {
        get
        {
            return _name;
        }

        set
        {
            _name = value;

            // action when changing the name takes place here...
        }
    }
}

So the “_name” property is mapped to the database, but is kept protected/internal so that it cannot be modified directly. And the second public property “Name” provides the actual access.

The reason I have it set up this way, is because if that action was built directly into the mapped “_name” property’s set-method, it would be triggered when an object is hydrated from the database, which is not what I want.

This all works fine as such.

The problem is, when you need to query this type, attempting to query Person.Name won’t work, because that property isn’t mapped!

What I dislike about this, is the fact that you’re writing code against Person.Name, but have to write queries against Person._name, which is error-prone and confusing.

Is there a better way to solve this 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-05-27T18:09:52+00:00Added an answer on May 27, 2026 at 6:09 pm

    Can you use nosetter.camelcase-underscore for the access in the mapping? This would set the field directly (if named correctly, eg _name) instead of using the property setter.

    eg:

    <property name="Name" column="Name" type="String" access="nosetter.camelcase-underscore"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few arrays and a resource that needs deletion, the value of
I have run into a few cases where i have been asked to deploy
In our code we have quite a few cases of this pattern: class outerClass
I am writing a few test cases that depend on the database being available,
I would like to know a few practical use-cases (if they are not related/tied
I have a few properties defined in my header file like so @property (assign)
I have a project that was compiled with the Flex 3.2 SDK. One of
I have a few modules, but I will focus on one in particular. This
I have been coding in iphone platform for about a few months. One thing
We are using JAXB to generate Java classes and have encountered a few cases

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.