Nhibernate 我如何编写一个HQL来获取它?
我有一门课叫《大陆与国家》 大陆级有国家/地区系列:Nhibernate 我如何编写一个HQL来获取它?,nhibernate,hql,Nhibernate,Hql,我有一门课叫《大陆与国家》 大陆级有国家/地区系列: private ISet<Country> _countries; public virtual ISet<Country> Countries { get { return _countries; } set { _countries = value; } } 我的.hbm.xml文件包含大陆和国家对象的数据库关系信息 我应该如何在此处编写HQL: p
private ISet<Country> _countries;
public virtual ISet<Country> Countries
{
get { return _countries; }
set { _countries = value; }
}
我的.hbm.xml文件包含大陆和国家对象的数据库关系信息
我应该如何在此处编写HQL:
public IList<Continent> GetContinentsWithCountriesStartingWithLetter(char letter)
{
string query = ":letter"; //The query to be used
return
_session
.CreateQuery(query)
.SetString("letter", letter.ToString())
.List<Continent>();
}
public IList获取大陆的国家/地区从字母开始(字符字母)
{
string query=“:letter”//要使用的查询
返回
_会议
.CreateQuery(查询)
.SetString(“字母”,字母.ToString())
.List();
}
谢谢 return\u会话
return _session
.CreateQuery("from continent in Continent inner join continent.Countries country where country.Name like :letter")
.SetString("letter", letter)
.List<Continent>();
.CreateQuery(“从大陆内部的大陆连接大陆。国家所在国家。名称如:字母”)
.SetString(“字母”,字母)
.List();
Boogart:谢谢!你能给我推荐一个涵盖所有HQL语法和用法的好资源吗?@burak:我不认为这很好,但是你手头有NH用户指南吗?你应该抓起PDF文件,把它放在你所做的任何地方。@Kent Boogart:我想你的意思是:谢谢你,Kent@burak:SourceForge上有NH特定的版本:。老实说,您仍然可以在NH文档中看到Java残余,但我认为使用NH文档会更好,这可能有助于避免一些混淆。
return _session
.CreateQuery("from continent in Continent inner join continent.Countries country where country.Name like :letter")
.SetString("letter", letter)
.List<Continent>();