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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:23:11+00:00 2026-05-16T22:23:11+00:00

I am trying to build a domain model that will allow me to manage

  • 0

I am trying to build a domain model that will allow me to manage Contracts.

The Contract class is my aggregate root, and it has a single property right now, which is Reviewers.

Reviewers, in the context of the Contract, each have a property to it’s parent Contract, and a First Name, Last Name, and Login. The reason they have these properties is so I can have the user select which Reviewers they want on a Contract.

The database that I’m tying my domain model to already exists, and it’s a legacy system that I’m trying to extend.

It has a Contract Table, and a Reviewer Table.

The thing I haven’t mentioned up until this point, is that Reviewers are actually Users in the system. So there’s actually a third table involved, which is Users.

I have been able to map my Contract Table easily with FNH.

It looks something like this:

public class ContractMapping: ClassMap<Contract>
{
    public ContractMapping()
    {
        Id(c => c.Id);
        HasMany(c => c.AdditionalReviewers);
    }
}

But I’m not sure how to model my Reviewers, because they are in fact Users as well. So my object model looks like this:

public class Reviewer: User
{
    public virtual Guid Id { get; set; }

    public virtual Contract Contract { get; set; }
}

public class User
{
    public virtual Guid Id { get; set; }

    public virtual string Login { get; set; }
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }        
}

I’ve been able to map my User class properly, and it looks something like this:

public class UserMapping: ClassMap<User>
{
    public UserMapping()
    {
        Id(u => u.Id);
        Map(u => u.Login);
        Map(u => u.FirstName);
        Map(u => u.LastName);
    }
}

and I believe I want to map my Reviewer class like this:

public class ReviewerMapping: SubclassMap<Reviewer>
{
    public ReviewerMapping()
    {
        Table("Reviewer");

        //Id(r => r.Id).Column("ReviewerId"); <- won't compile
        References(r => r.Contract).Column("ContractId");
    }
}

So the problem I’m having is this:

The relationship between the User table and the Reviewer table is one to many. Meaning, for a given User there may be many Reviewer records. Why? Because a User has to be a Reviewer for a specific Contract. This causes an issue with the mapping, though, because the primary key for my Reviewer and the primary key for my User are completely different values, by necessity.

Also, because of the way I’m using Reviewer, when I create a new Reviewer, what I’m really trying to do is to associate a User with a Contract. I am not trying to create an entirely new User in the database.

What is the correct way for me to map Reviewer, knowing that in my domain model it is a subclass of User?

  • 1 1 Answer
  • 1 View
  • 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-16T22:23:11+00:00Added an answer on May 16, 2026 at 10:23 pm

    I don’t think Reviewer should inherit from User in the scenario you’ve described. I would have the Reviewer class hold a User object instead (composition over inheritance).

    If it helps you conceptualize it better, rename Reviewer to Review. That way you can stop thinking about it as a User since it really isn’t (multiple Reviewers in your current domain can be the same User, which doesn’t make much sense).

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

Sidebar

Related Questions

I'm trying to build a web server in node.js that will support cross-domain scripting,
We are trying to build a cross-domain single-sign on solution using ASP.NET MVC. Any
I'm trying to build a widget that will be hosted on 3rd party sites.
I'm trying build a MVC framework, but I'm confused about manage themes. Well... I
I am trying to build a set of domain classes for a legacy database
I'm trying to build a parser that would be able to extract the data
I have a dynamic page and am trying to build dynamic links (domain.com/#/page2/content/etc). If
I trying to build a dynamic query similar to: def domain = DomainName def
I'm trying to build a simple HTML table form that displays values from a
I'm trying to build an efficient string matching algorithm. This will execute in a

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.