Mam problem z implementacją generycznego interfejsu repozytorium - konkretnie z metodą Update. Mój interfejs wygląda jak poniżej:
public interface IRepository<T>
{
void Create(T t);
void Update(T t);
void Delete(T t);
IQueryable<T> Get();
}
implementacja interfejsu :
public class Repository<T> : IRepository<T> where T : EntityObject
{
private MyEntities Context = new MyEntities();
public void Create(T t)
{
if (t == null)
{
throw new ArgumentNullException("entity");
}
Context.CreateObjectSet<T>().AddObject(t);
Context.SaveChanges();
}
public void Update(T t)
{
if (t == null)
{
throw new ArgumentNullException("entity");
}
Context.CreateObjectSet<T>().ApplyCurrentValues(t);
Context.SaveChanges();
}
public void Delete(T t)
{
if (t == null)
{
throw new ArgumentNullException("entity");
}
Context.CreateObjectSet<T>().DeleteObject(t);
Context.SaveChanges();
}
public IQueryable<T> Get()
{
return Context.CreateObjectSet<T>();
}
}
działa wszystko z wyjątkiem metody Update (argument t się przekazuje, ale samo Context.CreateObjectSet<T>().ApplyCurrentValues(t) nie wprowadza żadnych zmian).
Nie zwraca ani błędy, ani wyjątku.
Ma ktoś może pomysł co z tym zrobić?