Created
March 16, 2011 19:45
-
-
Save skoon/873165 to your computer and use it in GitHub Desktop.
So this is what I had to do to get a composite key to work
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
public class ScrewturnPageKeyword | |
{ | |
private int? _hashCode; | |
public virtual string Page { get; set; } | |
public virtual string Namespace { get; set; } | |
public virtual int Revision { get; set; } | |
public virtual string Keyword { get; set; } | |
public override bool Equals(object obj) | |
{ | |
if (obj == null) return false; | |
if (this == obj) return true; | |
var pk = obj as ScrewturnPageKeyword; | |
return (this.Page == pk.Page | |
&& this.Namespace == pk.Namespace | |
&& this.Keyword == pk.Keyword); | |
} | |
public override int GetHashCode() | |
{ | |
if (!_hashCode.HasValue) | |
_hashCode = base.GetHashCode(); | |
return _hashCode.Value; | |
} | |
} | |
public class PageKeywordMappings : ClassMap<ScrewturnPageKeyword> | |
{ | |
public PageKeywordMappings() | |
{ | |
Table("PageKeyword"); | |
CompositeId() | |
.KeyProperty(m => m.Page) | |
.KeyProperty(m => m.Keyword) | |
.KeyProperty(m => m.Namespace); | |
Map(m => m.Revision); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment