2
我有一個基類,有一些屬性和行爲。這個基類被許多其他類擴展/繼承。其中一些類應該在其自己的屬性之一和基類的一個屬性上創建唯一的多列索引。在繼承的非重寫字段上的多列索引
public class BaseClass
{
long employeeId {get; set;}
// and many other things...
}
public class Buzzword : BaseClass
{
string Name {get;set;} // supposed to be unique for every employee
// many other things...
}
我想什麼是現在這樣的事情,我重複類流行語:
public class Buzzword : BaseClass
{
[Index("IX_Buzzword_EmployeeId_Name", IsUnique = true, Order = 1]
// black magic: inherited property of BaseClass
[Index("IX_Buzzword_EmployeeId_Name", IsUnique = true, Order = 2]
string Name {get;set;} // supposed to be unique for every employee
// many other things...
}
我怎樣才能做到這一點?使employeeId爲虛擬(因此仍然在所有子類中實現),並在用於多列索引定義的類(以及對基本實現的調用)中覆蓋它?
親切的問候, 隊友
請仔細閱讀並考慮修改您的標題以刪除標籤:http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles –