gpt4 book ai didi

NHibernate "Errors in named queries"

转载 作者:行者123 更新时间:2023-12-03 12:24:03 25 4
gpt4 key购买 nike

我定义了以下命名 SQL 查询:

<sql-query name="ItemSearch">
<return class="ItemSearchResult">
<return-property name="Item" column="ItemId" />
<return-property name="Distance" column="Distance" />
</return>
SELECT
Items.*,
dbo.DistanceBetween(Latitude, Longitude, :lat, :long) AS Distance
FROM Items
WHERE Contains(Name, :keywords)
ORDER BY Distance ASC
</sql-query>

每当我尝试运行我的应用程序时,都会收到一般错误“命名查询中的错误:{ItemSearch}”。这里有什么明显的错误吗?

ItemSearchResult 类是一个非常简单的包装类,如下所示:
public class ItemSearchResult
{
public Item Item {get; set;}
public double Distance {get; set;}
}

最佳答案

你有正确的.hbm.xmlItemSearchResult ?如果您使用 ItemSearchResult在您的查询中,您需要有一个 .hbm.xml为了它。就像实体一样。

关于NHibernate "Errors in named queries",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1738929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com