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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:17:08+00:00 2026-05-27T13:17:08+00:00

Using NHibernate and Fluent Mappings. We have a property (Groupable) of a class (GroupAssignment)

  • 0

Using NHibernate and Fluent Mappings.

We have a property (Groupable) of a class (GroupAssignment) which implements an interface (IGroupable). Another property on the same class is an enumeration (ItemType) which specifies where the IGroupable is sourced from, i.e. which table.

Can we map this configuration so that NHibernate populates the IGroupable property, linking to the correct table based on the Enum discriminator? If so, how can we achieve this?

Please note the IGroupable property has a one to one relationship with GroupAssignment class.

public class GroupAssignment
{
    public virtual new long ID { get; private set; }
    public virtual Group Group { get; set; }
    public virtual TypeEnum.TypeGroupItem ItemType { get; set; }
    public virtual IGroupable Groupable { get; set; }
}

Ideally NHibernate should get the IGroupable from
TableA when ItemType == TableA,
TableB when ItemType == TableB etc.

I should also add that each of the tables directed by the ItemType enum are mapped to classes which implement the IGroupable 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-05-27T13:17:09+00:00Added an answer on May 27, 2026 at 1:17 pm

    You can achieve this with <any>. You don’t even need the enum; NHibernate will take care of setting the correct discriminator based on the concrete Groupable.

    Check out 5.2.4. Any type mappings

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

Sidebar

Related Questions

I'm using Fluent NHibernate, and auto-mapping the classes. I have a computed property in
I have dictionary which I'm mapping using Fluent NHibernate. The dictionary has a complex
I've just started using NHibernate and fluent-NHibernate which I think is great. I've been
I have a Sharp Architecture based app using Fluent NHibernate with Automapping. I have
Using Nhibernate and Fluent NHibernate for the mapping, I have a parent entity with
I have been unable to persist a nullable enum using NHibernate with Fluent NHibernate
I've inherited a bunch of Fluent NHibernate mappings, which all currently work in the
I have problem using Fluent Nhibernate, I have following model. When I try to
Using the fluent-nhibernate mappings, I am trying to meet a requirement to create the
I have two classes mapped using fluent NHibernate - User and a UserRoleAssignment. An

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.