因爲我支持我的數據庫軟刪除,我選擇了分型我Thing
實體ActiveThing
和DeletedThing
...在實體框架中使用TPH時,如何讓我的OData僅暴露特定類型?
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// TPH (table-per-hierarchy):
modelBuilder.Entity<MyCorp.Biz.CoolApp.Thing>()
.Map<MyCorp.Biz.CoolApp.ActiveThing>(thg => thg.Requires("Discriminator").HasValue("A"))
.Map<MyCorp.Biz.CoolApp.DeletedThing>(thg => thg.Requires("Discriminator").HasValue("D"));
}
現在,我的OData端點(其前身暴露Thing
)。 。我該如何獲得它現在只暴露ActiveThing
s?
偏離主題,但:我想知道,你的刪除代碼是什麼? – tschmit007
如果你想看到它,我發佈我的ODataController的DELETE方法通過[here](http://stackoverflow.com/a/43639301/1520850) – bkwdesign
謝謝。您使用Raw Sql,這是我懷疑的。我更喜歡一個允許完整linq到實體語法的解決方案:)。 – tschmit007