我有一個包含屬性的對象,該屬性是SQL語句的結果。如何將SQL語句添加到我的nHibernate映射文件中?使用SQL查詢來填充nHibernate映射文件中的屬性
例子中的物體:
public class Library{
public int BookCount
{
get;
set;
}
}
實例映射文件:
<hibernate-mapping>
<class name="Library" table="Libraries">
<property name="BookCount" type="int"> <- This is where I want the SQL query to populate the value. ->
</class>
</hibernate-mapping>
實例SQL查詢:
SELECT COUNT(*) FROM BOOKS WHERE BOOKS.LIBRARY_ID = LIBRARIES.ID