我有一個自定義的DbContext它的名字是的DbContext(https://github.com/bilal-fazlani/tracker-enabled-dbcontext)。我想用它來做審計日誌我如何可以使用自定義的DbContext(審計日誌)與sharprepository
我怎樣才能實現EFRepository啓用跟蹤,?
我實現了跟蹤器啓用上下文,但我無法解決如何覆蓋尖銳回購提交方法。
public class HayEntities : TrackerContext
{
static HayEntities()
{
Database.SetInitializer<HayEntities>(null);
}
public HayEntities() : base(HayEntities)
{
this.Configuration.ProxyCreationEnabled = false;
this.Configuration.LazyLoadingEnabled = true;
this.Configuration.ValidateOnSaveEnabled = false;
}
public DbSet<Dummy> Dummys{ get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new DummyConfiguration());
} }
}
public class DummyRepository : ConfigurationBasedRepository<DE.Dummy, long>, IDummyRepository
{
private readonly IRepository<DE.Dummy, long> _servisHasarRepository;
public DummyRepository (HayEntities hayEntities, ICachingStrategy<DE.Dummy, long> cachingStrategy = null)
{this.CachingEnabled = false;
_dummyRepository = new EfRepository<DE.Dummy, long>(hayEntities, cachingStrategy);
}
public void UpdateOrCreate() {
//In this area how can override save/commit method
}
}
嗨。你能告訴我們你到目前爲止所嘗試過的,所以我們可以幫助你。 –