GetPrimaryKeyValue() public method

public GetPrimaryKeyValue ( object entity ) : object
entity object
return object
Example #1
0
 public void NonGenericPrimaryKeyGetterWorks() {
     var map = new Map<Post>();
     map.Columns.Add("PostId", new Column<int> { IsPrimaryKey = true, Map = map, Name = "PostId" });
     map.PrimaryKey = map.Columns["PostId"];
     var post = new Post { PostId = 123 };
     Assert.Equal(post.PostId, map.GetPrimaryKeyValue((object)post));
 }
Example #2
0
 public void UsePrimaryKeyGetterWithoutPrimaryKeyColumnThrow() {
     var map = new Map<Post>();
     map.Columns.Add("PostId", new Column<int> { IsPrimaryKey = true, Map = map, Name = "PostId" });
     var post = new Post { PostId = 123 };
     Assert.Throws<Exception>(() => map.GetPrimaryKeyValue(post));
 }