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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:16:41+00:00 2026-05-18T21:16:41+00:00

Taking the following object model: public abstract class Entity { public Guid Id {

  • 0

Taking the following object model:

public abstract class Entity
{
    public Guid Id { get; set; }
}

public class Category : Entity
{
    public string Name { get; set; }

    public ICollection<LocalizedProperty> LocalizedProperties { get; set; }
}

public class Product : Entity
{
    public string Name { get; set; }

    public ICollection<LocalizedProperty> LocalizedProperties { get; set; }
}

public class LocalizedProperty : Entity
{
    public string CultureName { get; set; }
    public string PropertyName { get; set; }
    public string PropertyValue { get; set; }
}

Is it possible to use a type discriminator along with the entity’s Id as the foreign key. The idea is that the resultant LocalizedProperties table would be:

LocalizedProperties
-------------------
Id
EntityType
EntityId
CultureName
PropertyName
PropertyValue

I know this is possible using Table-per-subclass mapping where each of my “Localized” entities inherit from a base localized entity class, which in turn has the association with LocalizedProperty. However, I would rather not have this extra level of inheritance if the above is possible.

Thanks,
Ben

UPDATE

Thanks to Diego for providing the solution using confORM. For those of you using traditional mapping files, I have converted the example from http://fabiomaulo.blogspot.com/2010/11/conform-any-to-many.html

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" namespace="ConfOrm.UsageExamples.CreateXmlMappingsInBinFolder" assembly="ConfOrm.UsageExamples" xmlns="urn:nhibernate-mapping-2.2">
  <class name="Blog">
    <id name="Id" type="Guid">
      <generator class="guid.comb" />
    </id>
    <property name="Title" />
    <property name="Subtitle" />
    <set name="Tags" cascade="all" where="TagedItemClass = 'ConfOrm.UsageExamples.CreateXmlMappingsInBinFolder.Blog'">
      <key column="TagedItemId" foreign-key="none" />
      <one-to-many class="Tag" />
    </set>
  </class>
</hibernate-mapping>

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" namespace="ConfOrm.UsageExamples.CreateXmlMappingsInBinFolder" assembly="ConfOrm.UsageExamples" xmlns="urn:nhibernate-mapping-2.2">
  <class name="Tag">
    <id name="Id" type="Guid">
      <generator class="guid.comb" />
    </id>
    <property name="Name" />
    <any id-type="Guid" name="TagedItem">
      <column name="TagedItemClass" />
      <column name="TagedItemId" />
    </any>
  </class>
</hibernate-mapping>
  • 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-18T21:16:42+00:00Added an answer on May 18, 2026 at 9:16 pm

    You can use <any>.

    http://nhibernate.info/doc/nh/en/index.html#mapping-types-anymapping

    For a full example, check http://fabiomaulo.blogspot.com/2010/11/conform-any-to-many.html. I think it’s exactly what you need.

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

Sidebar

Related Questions

Consider the following snippet: public class ReflectionTest { public static void main(String[] args) {
Taking a classic foo bar example: In models.py : Class Foo(models.Model): name = models.CharField(max_length=
Suppose we have following two classes: class Temp{ public: char a; char b; };
Hey Just wondering how the following can happen Object reference not set to an
Taking the following Model: MyModel= Backbone.Model.extend({ defaults : { myNestedModel:undefined, }, initialize: function() {
I have 2 objects with attributes as the following: Object 1: Person Name Location
The following query is taking more than 25 seconds to complete: SELECT c.* ,
By taking into consideration the following code snipped: if('<?= Yii::app()->controller->action->id?>' == 'create'){ $(#Event_name).focusout(function(){ $.ajax({
Taking a rails tutorial, and I've run into the following problem that I'm having
I've got the following code that's taking photos from a flickr feed via JSON

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.