我搜索了很多關於如何使用EntityFramework或NHibernate映射多重繼承或多接口植入但我沒有發現任何有用的東西。如何使用NHibernate映射多個接口實現
我只是希望這種結構使用NHibernate映射:據我所知,這種結構映射到關係數據庫
public interface IA
{
string A { get; set; }
}
public interface IB
{
string B { get; set; }
}
public class C : IA, IB
{
string A { get; set; }
string B { get; set; }
}
意味着只是爲了與接口的主鍵與外鍵,因此接口應有這樣的按鍵:
public interface IA
{
Guid AId { get; set; }
string A { get; set; }
}
public interface IB
{
Guid BId { get; set; }
string B { get; set; }
}
public class C : IA, IB
{
public virtual Guid AId { get; set; }
public virtual Guid BId { get; set; }
public virtual string A { get; set; }
public virtual string B { get; set; }
}
但如何使用NHibernate或者的EntityFramework映射這個結構,我不知道爲什麼多接口映射不是他們的文檔中提及!
我剛剛編輯我的問題,因爲它似乎導致誤導,我想看看我怎麼可以映射它在NHibernate例如! – Hogaf 2011-04-03 11:20:10
我也想要另一個實現了IA接口的類,所以稍後我會查詢IA接口。 – Hogaf 2011-04-03 11:30:21
@Hossein:這是否有幫助:http://stackoverflow.com/questions/3612816/nhibernate-query-all-objects-implementing-an-interface? – 2011-04-03 11:45:53