Created
October 24, 2012 19:04
-
-
Save chester89/3948140 to your computer and use it in GitHub Desktop.
One to many from a derived class to other entity generates weird mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product | |
{ | |
public int ProductId { get; set; } | |
} | |
class SpecialProduct : Product | |
{ | |
public ICollection<Option> Options { get; set;} | |
} | |
class Option | |
{ | |
public int OptionId { get; set; } | |
public SpecialProduct Back { get; set; } | |
} | |
class ProductMap : ClassMap<Product> | |
{ | |
public ProductMap() | |
{ | |
Id(x => x.ProductId); | |
} | |
} | |
class SpecialProductMap : SubclassMap<SpecialProduct> | |
{ | |
public SpecialProductMap() | |
{ | |
Extends<Product>(); | |
HasMany(x => x.Options).Cascade.AllDeleteOrphan(); | |
} | |
} | |
class OptionMap : ClassMap<Option> | |
{ | |
public OptionMap() | |
{ | |
Id(x => x.OptionId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment