我如何编写 HQL 来获取它?
我有一个叫做大陆和国家的课程。
大陆类具有国家/地区集合:
private ISet<Country> _countries;
public virtual ISet<Country> Countries
{
get { return _countries; }
set { _countries = value; }
}
我想编写一个 HQL 查询,该查询将获取所有拥有国家/地区的大陆,至少有一个国家/地区的 CountryName =“A”
我的国家/地区类具有属性:
public virtual string CountryName { get; set; }
并且我有我的 . hbm.xml 文件包含 Continent 和 Country 对象的 Db 关系信息。
我应该如何在这里写我的 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>();
}
谢谢!
I have a class called Continent and Country.
Continent class has Country collection:
private ISet<Country> _countries;
public virtual ISet<Country> Countries
{
get { return _countries; }
set { _countries = value; }
}
I want to write an HQL query that will get all the continents that have countries at least one country with CountryName = "A"
My country class has property:
public virtual string CountryName { get; set; }
And I have my .hbm.xml files have the Db relation information for both the Continent and Country objects.
How should I write my HQL here:
public IList<Continent> GetContinentsWithCountriesStartingWithLetter(char letter)
{
string query = ":letter"; //The query to be used
return
_session
.CreateQuery(query)
.SetString("letter", letter.ToString())
.List<Continent>();
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)