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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:11:45+00:00 2026-06-08T16:11:45+00:00

Edit I’ve got an interface that I’d like to base some classes on. When

  • 0

Edit

I’ve got an interface that I’d like to base some classes on. When I go to BuildSchema (or UpdateSchema), Nhibernate creates a table for the interface. I thought I found a work-around as follows:

The Interface and Classes:

public interface ILevel
{
    int Id { get; set; }
    string Name { get; set; }
}
public abstract class Level : ILevel
{
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
}
public class LevelOne : Level { }
public class LevelTwo : Level { }

The Mappings:

public class LevelMap : ClassMap<ILevel>
{
    public LevelMap()
    {
        Id(x => x.Id);
        Map(x => x.Name);
    }
}
public class LevelOneMap : SubclassMap<LevelOne>
{
}
public class LevelTwoMap : SubclassMap<LevelTwo>
{
}

This doesn’t work (I did another UpdateSchema and the pesky ILevel table appeared).

Is there a configuration I’m unaware of to ignore interfaces/abstract classes altogether?

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

    For seperate tables LevelOne and LevelTwo, that both have the properties of Level/ILevel, use a generic mapping for Level:

    public abstract class LevelMap<T> : ClassMap<T>
        where T : Level  // ILevel should work, too
    {
        protected LevelMap()
        {
            Id(x => x.Id);
            Map(x => x.Name);
        }
    }
    
    public class LevelOneMap : LevelMap<LevelOne>
    {
    }
    
    public class LevelTwoMap : LevelMap<LevelTwo>
    {
    }
    

    You provide two separate class mappings without telling Fluent the real class hierarchy.

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

Sidebar

Related Questions

Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: See my answer below--> I am wanting to have a view that when
EDIT: iam using ajax to load text in my content that is why onload
Edit : Note that, as Daniel and latkin noted in an answer and a
EDIT : It turned out that this can only be done through an external
Edit: I would like to model a 1 to 0:1 relationship between User and
Edit: an important piece might be that I'm calling a cfc method via ajax...
Edit ok, great feedback here, got me pointed in the right direction. Use case
EDIT: Sorry about ellipsis that's not what I actually have. For declaring an array

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.