GetObjectById, , , , . , , , , . , , Id. .
public Repository(...)
{
GetByIdAccepted = ExamineIdKey();
}
protected bool ExamineIdKey()
{
return typeof(TModel).GetMember("Id", BindingFlags.Instance | BindingFlags.Public).Length > 0;
}
public TModel GetById(object id)
{
if(!GetByIdAccepted)
throw new InvalidOperationException("error text");
object model;
if (Connection.TryGetObjectByKey(new EntityKey(EntityName, "Id", id), out model))
return (TModel)model;
return null;
}