Criteria API 和字典/地图上的左连接
我有以下类:
public class Item
{
public int Id { get; set; }
public IDictionary<int, ItemLocal> { get; protected set; }
public ICollection<string> Tags { get; set; }
public int DefaultLanguageId { get; set; }
public DateTime Start { get; set; }
}
public class ItemLocal
{
public virtual Item Parent { get; set; }
public virtual int LanguageId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
这些类映射到表 Item、ItemTag 和 ItemLocal。我想通过 criteria api 进行以下查询:
select
i.Id,
i.Start,
l.Title
from
Item i
left join ItemLocal l on i.Id = l.ParentId and i.DefaultLangaugeId = l.LanguageId
order by
l.Title,
i.Id
但我不知道如何使用 nhibernate criteria api 执行左连接。特别是使用默认语言选择时。
非常感谢任何帮助。
I have the following classes:
public class Item
{
public int Id { get; set; }
public IDictionary<int, ItemLocal> { get; protected set; }
public ICollection<string> Tags { get; set; }
public int DefaultLanguageId { get; set; }
public DateTime Start { get; set; }
}
public class ItemLocal
{
public virtual Item Parent { get; set; }
public virtual int LanguageId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
These map to the tables Item, ItemTag and ItemLocal. I want to make the following query via the criteria api:
select
i.Id,
i.Start,
l.Title
from
Item i
left join ItemLocal l on i.Id = l.ParentId and i.DefaultLangaugeId = l.LanguageId
order by
l.Title,
i.Id
But I dont know how to perform the left join with the nhibernate criteria api. Especially with the usage of the default language selection.
Any help is very appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个解决方案:
这似乎可行,但会导致使用解决方法 WHERE 子句的查询。宁愿看到它可以呈现一个 SQL 查询,其中析取中定义的限制可以是 OUTER LEFT JOIN ... ON ... 语句的一部分。
I have found a solution:
This seems to work but results in a query with a workaround WHERE clause. Would rather see that it could render a SQL query where the restrictions defined in the disjunction could be part of the OUTER LEFT JOIN ... ON ... statement.