Skip to content

Instantly share code, notes, and snippets.

@chester89
Created October 24, 2012 19:04
Show Gist options
  • Save chester89/3948140 to your computer and use it in GitHub Desktop.
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
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