Browse Source

Document IEntity.GetKeys() method.

pull/395/head
Halil ibrahim Kalkan 8 years ago
parent
commit
c9398a4dee
  1. 7
      docs/Entities.md

7
docs/Entities.md

@ -45,11 +45,18 @@ public class UserRole : Entity
{
}
public override object[] GetKeys()
{
return new object[] { UserId, RoleId };
}
}
````
For the example above, the composite key is composed of `UserId` and `RoleId`. For a relational database, it is the composite primary key of the related table.
Entities with composite keys should implement the `GetKeys()` method as shown above.
Notice that you also need to define keys of the entity in your **object-to-relational mapping** (ORM) configuration.
> Composite primary keys has a restriction with repositories. Since it has not known Id property, you can not use `IRepository<TEntity, TKey>` for these entities. However, you can always use `IRepository<TEntity>`. See repository documentation (TODO: link) for more.

Loading…
Cancel
Save