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

  • Home
  • SEARCH
  • 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 7053063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:27:33+00:00 2026-05-28T03:27:33+00:00

My application has the following types defined public interface IUser { int Id {

  • 0

My application has the following types defined

public interface IUser {
   int Id { get; set; }
   int UserName { get; set; }
}

public class User : IUser {
   public virtual int Id { get; set; }
   public virtual string UserName { get; set; }
}

The User class is fluently mapped like:

public class UserMap : ClassMap<User> {
    public UserMap() {
        Table("Users");
        Id(x => x.Id);
        Map(x => x.UserName);
    }
}

I’d like to create another implementation of IUser but i have a couple restrictions:

  1. The new fields must be added to the same table as the Users table
  2. The code to extend the type exists in a seperate project

For example here is my new class:

public class CustomUser : IUser {
   public virtual int Id { get; set; }
   public virtual string UserName { get; set; }
   public virtual string Name { get; set; }
}

Which is mapped like:

public class CustomUserMap : ClassMap<CustomUser> {
    public CustomUserMap() {
        Table("Users");
        Id(x => x.Id);
        Map(x => x.UserName);
        Map(x => x.Name);
    }
}

The first problem i had with this was that it did not like the same interface to be mapped twice. I overcame this by adding some code in the Application_Start event to only add the UserMap class if no CustomUserMap class existed.

However i soon ran into my next problem, if i add a reference to the IUser interface in another type, it throws the error:

An association from the table Blogs refers to an unmapped class: IUser

I’m probably going about things completely wrong and i’d appreciate it if someone could show me what i’m doing wrong. Thanks

  • 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-28T03:27:34+00:00Added an answer on May 28, 2026 at 3:27 am

    If you want them to map to the same table, why don’t you inherit User? That will also implement the IUser interface.

    In order to prevent duplicate selects (when fetching User, it might fetch the CustomerUser in a second roundtrip), you need to specify polymorphism explicit on the User class. In hbm files this would be polymorphism=”explicit”, don’t know about fluent nhibernate.

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

Sidebar

Related Questions

I have a legacy VB6 application that has the following structure defined: Public Type
In a Silverlight project, I've got the following class defined. public class ThemeResource<T> {
I have following model class in my application: public class Dispute { public long
My android application has several warnings of the following form when I run it
I'm building WPF client application. I'm following MVC pattern. The project solution has many
My application has a need to let the user choose a date from a
My application has a command line interface, and I'm thinking about using the GNU
In my application, I have defined the following style for TextBlocks. <Style TargetType={x:Type TextBlock}>
Application has an auxiliary thread. This thread is not meant to run all the
Our application has a file format similar to the OpenDocument file format (see http://en.wikipedia.org/wiki/OpenDocument

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.