I have the following classes:
public class Item
{
    public int Id { get; set; }
    public IDictionary<int, ItemLocal> { get; protected set; }
    public ICollection<stri开发者_运维问答ng> 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.
I have found a solution:
Session
   .CreateCriteria<Item>("i")
   .CreateCriteria("Localization", "l", NHibernate.SqlCommand.JoinType.LeftOuterJoin)
      .Add(Restrictions.Disjunction()
         .Add(Restrictions.EqProperty("i.DefaultLanguageId", "l.LanguageId"))
         .Add(Restrictions.IsNull("l.LanguageId"))
      )
   .AddOrder(Order.Asc("l.Title"))
   .AddOrder(Order.Asc("w.Id"));
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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论