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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:29:39+00:00 2026-05-12T13:29:39+00:00

I have the following idea: Business object implemented as interface or abstract class with

  • 0

I have the following idea:

Business object implemented as interface or abstract class with certain properties as read only to all layers except the DAL layer. I also want my business objects in another assembly than the DAL (for testing purposes), so marking the properties is not an option for me.

Examples could be one to one relationships or other properties.

I have almost solved the issue by doing the following

abstract class User
{
    public virtual long UserId {get; protected set;}
    public virtual string Password {get; protected set;}
    ...
}

In the DAL:

public class DbUser : User
{
    internal virtual void SetPassword(string password) {...}
}

I then map this using fluent as

ClassMap<User> {...}
SubclassMap<DbUser> {...}

The problem I get is that fluent tries to create a table named DbUser.

If I skip the SubclassMap and creates a DbUser object and tries to save it I get an “No persister for this object” error.

Is it possible to solve?

  • 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-12T13:29:39+00:00Added an answer on May 12, 2026 at 1:29 pm

    You could probably override what is done with Fluent

    public class DbUser: IAutoMappingOverride<DbUser>
        {
            public void Override(AutoMapping<DbUser> mapping)
            {
                //tell it to do nothing now, probably tell it not to map to table,
                // not 100% on how you'd do this here.                    
            }
        }
    

    Or you could have an attribute

    public class DoNotAutoPersistAttribute : Attribute
    {
    }
    

    And in AutoPersistenceModelGenerator read for attribute in Where clause to exclude it.

    Check would be something like

    private static bool CheckPeristance(Type t) { 
                var attributes = t.GetCustomAttributes(typeof (DoNotAutoPersistAttribute), true); 
                Check.Ensure(attributes.Length<=1, "The number of DoNotAutoPersistAttribute can only be less than or equal to 1"); 
                if (attributes.Length == 0) 
                    return false;
                var persist = attributes[0] as DoNotAutoPersistAttribute; 
                return persist == null; 
            } 
    

    Then it kind of depends how you’re adding entities but you’re probably adding via assembly so this might do it for you:

    mappings.AddEntityAssembly(typeof(User).Assembly).Where(GetAutoMappingFilter);
    ....
    ...
    private static bool GetAutoMappingFilter(Type t)
            {
                return t.GetInterfaces().Any(x => CheckPeristance(x)); //you'd probably have a few filters here
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this possible at all? The idea is to have the following: if ($some_statement)
I've got a situation where I have a business object with about 15 properties
I have following codes in python2.x: class _CHAIN(object): def __init__(self, execution_context=None): self.execution_context = execution_context
I had the following idea: Say we have a webapp written using django which
I have following problem, Code: String a=Yeahh, I have no a idea what's happening
has anyone an idea why I have the following problem with passing locals to
The idea is that say you have the following table. ------------- | oID |
Having a deadlock in webservice + hibernate... No idea why. I have the following
I have no idea why this wont work but I have tried the following:
I have no idea why I'm getting this following error: Control cannot fall through

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.