エンティティの汎用リポジトリがあり、すべてのエンティティ(コード生成アイテムによって生成される)には、IIDインターフェイスを実装するパーソナライズされたパーシャルがあります。この時点で、すべてのエンティティにInt32Idプロパティが必要です。
だから、私の問題はアップデートにあります、ここに私のコードがあります
public class RepositorioPersistencia<T> where T : class
{
public static bool Update(T entity)
{
try
{
using (var ctx = new FisioKinectEntities())
{
// here a get the Entity from the actual context
var currentEntity = ctx.Set<T>().Find(((BLL.Interfaces.IID)entity).Id);
var propertiesFromNewEntity = entity.GetType().GetProperties();
var propertiesFromCurrentEntity = currentEntity.GetType().GetProperties();
for (int i = 0; i < propertiesFromCurrentEntity.Length; i++)
{
//I'am trying to update my current entity with the values of the new entity
//but this code causes an exception
propertiesFromCurrentEntity[i].SetValue(currentEntity, propertiesFromNewEntity[i].GetValue(entity, null), null);
}
ctx.SaveChanges();
return true;
}
}
catch
{
return false;
}
}
}
誰かが私を助けることができますか?これは私を夢中にさせます。