Created
October 25, 2010 13:53
-
-
Save hotgazpacho/644989 to your computer and use it in GitHub Desktop.
Abstract base class with multiple subclasses. Some subclasses have additional properties in DetailXXX tables. DB lacks FK relationships. Relationships are mapped on "natural" composite keys.
This file contains hidden or 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
| // Component is an abstract base class | |
| // Weld inherits from Component | |
| // Weld has additional properties in DetailWeld table | |
| public class ComponentMap : ClassMap<Component> | |
| { | |
| public ComponentMap() | |
| { | |
| Table("Component"); | |
| CompositeId().KeyProperty(x => x.ItemId).KeyProperty(x => x.RevNo); | |
| // Properties mapped here | |
| DiscriminateSubClassesOnColumn("ComponentTypeId", 4); | |
| } | |
| } | |
| public class WeldMap : SubclassMap<Weld> | |
| { | |
| public WeldMap() | |
| { | |
| DiscriminatorValue(8); | |
| Join("DetailWeld", | |
| wd => | |
| { | |
| wd.KeyColumn("ItemId"); | |
| wd.KeyColumn("RevNo"); | |
| //More properties mapped here | |
| }); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes on swapping the order of calls to KeyColumn.
FNH is 1.1 binary (1.1.0.685)