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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:03:10+00:00 2026-06-07T16:03:10+00:00

Given the classes below: public class Address : Place { public virtual string Street

  • 0

Given the classes below:

public class Address : Place
{
    public virtual string Street { get; set; }
    public virtual int Number  { get; set; }


    public override string WhereAmI
    {
        get { string.Format("{0} {1}", Street , Number); }
    }
}
public abstract class Place : DomainEntity
{
    public abstract string WhereAmI { get; }
}

When I use this mapping:

var autoMap = AutoMap.AssemblyOf<Party>()
            .Override<Place>(map => map.IgnoreProperty(p => p.WhereAmI))
            .Override<Address>(map => map.IgnoreProperty(p => p.WhereAmI))
            .Where(type => type.Namespace != null && type.Namespace.Contains("Models"));

I still get the error: Could not find a setter for property ‘WhereAmI’ in class ‘Address’

Things I did:

  • When i remove the property from the base class “Address” it works.
  • When i use .OverrideAll(map => map.IgnoreProperty(“WhereAmI”)) But I don’t want it to be global because in another class i might use the same property name where I DO want to include this Property

Is there any way to get this to work other then to use an Interface?

  • 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-07T16:03:11+00:00Added an answer on June 7, 2026 at 4:03 pm

    I tried tracking down in the FluentNHibernate code exactly why the IgnoreProperty seems to break down when the property being ignored is coming from a base class, but ran out of time. It seems to work fine if the get-only property is not coming from a base class.

    Anyway, the solution to your situation seems to be to create a custom IAutomappingConfiguration by inheriting from DefaultAutomappingConfiguration. See this stack overflow answer: How can I create a Fluent NHibernate Convention that ignores properties that don’t have setters.

    Here’s the custom automapping configuration that I used successfully to automap the example entity you provided:

    protected class CustomConfiguration : DefaultAutomappingConfiguration
    {
        public override bool ShouldMap (Member member)
        {
            if (member.IsProperty && member.IsPublic && !member.CanWrite)
            {
                return false;
            }
    
            return base.ShouldMap(member);
        }
    
        public override bool ShouldMap(Type type)
        {
            return type.Namespace != null && type.Namespace.Contains("Models");
        }
    }
    

    And then its use:

    var autoMap = AutoMap
                .AssemblyOf<DomainEntity>(new CustomConfiguration());
    

    Note that the Where clause in your example had to move into the custom configuration class as its not allowed to be chained if you are using a custom configuration instance.

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

Sidebar

Related Questions

I have two classes as below: [DataContract] public class Address { [DataMember] public string
Given these classes: using System.Collections.Generic; namespace FluentMappingsQuestion { public class Entity { public virtual
If I have the given below classes: class TestA { public: const TestA &operator=(const
Given the following classes: <?php class test{ static public function statfunc() { echo this
Given the following classes and interfaces class A{ @NotNull(groups=Section1.class) private String myString } interface
This is easier to explain with an example. Given these two classes: public class
Updated question given Andrew Hare's correct answer: Given the following C# classes: public class
There are two classes in my project like below: public class Teacher { public
My SessionContext class is given below,I want to set User property as SiteUserDomainModel(it is
I have two classes declared as below: class User { public: MyMessageBox dataMsgBox; };

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.