Replies: 5 comments 1 reply
-
Hi, you've mapped your classes as two separate entities, not as subclasses. So: |
Beta Was this translation helpful? Give feedback.
-
Hi, i tried that but i am getting this Error: If I remove "Table("FooTable")" from the mapping (FooTableExMap) i get the following error: The criteria is still the same: var crit = QueryOver.Of<FooTableEntity>()
.Where(x => x.Id == 1)
.DetachedCriteria; |
Beta Was this translation helpful? Give feedback.
-
It should be like this, if the table is the same in FooTableEx, don't specify.
|
Beta Was this translation helpful? Give feedback.
-
Hello, like i said before, if i remove the Table statement, i get this error: this is the class/mapping: using FluentNHibernate.Mapping;
namespace EntityInheritanceTest
{
public class FooTableExEntity : FooTableEntity
{
public virtual string Name { get; set; }
}
public class FooTableExMap : SubclassMap<FooTableExEntity>
{
public FooTableExMap()
{
//Table("FooTable");
Map(x => x.Name, "Name");
}
}
} |
Beta Was this translation helpful? Give feedback.
-
If you have objects of different types in the same table, how can NHibernate know which type it is? For this, you need to configure discriminators. The core documentation: https://nhibernate.info/doc/nhibernate-reference/mapping.html#mapping-declaration-discriminator (It's also available in FluentNHibernate). If you "track" object type by keeping subclasses in different tables (i.e. "joined-subclass") the discriminator is not necessary but in this case it doesn't make sense to try and force the same table to join with itself. Also, beware of any conventions you might have setup that messes with it. |
Beta Was this translation helpful? Give feedback.
-
Hello,
i got an Entity "FooTableExEntity" which inherits from "FooTableEntity".
So far so good.
If i QueryOver of the FooTableEntity-Type for a specific Id, i get 2 results (one for each Type of Entities).
I am not sure if this is a Bug, or a mapping Error.
Attached is a minimal Project to reproduce the behaviour including the Sql-Script.
If QueryOver of the FooTableExEntity-Type i only get 1 result.
NHibernate: 5.5.2
FluentNhibernate: 3.4.0
EntityInheritanceTest.zip
Beta Was this translation helpful? Give feedback.
All reactions