C#linq到Nhibernate(3.4.0.0)左连接

时间:2016-05-25 14:15:46

标签: c# linq nhibernate linq-to-nhibernate nhibernate-3

我有以下型号:

public class Product
{
    public int Id { get; set; }

    public string Name { get; set; }

    public int CategoryId{ get; set; }
}

public class Category
{
    public int Id { get; set; }

    public string Name { get; set; }
}

我正在尝试使用Products查询Category模型和group join:

var categoryList = (from c in session.Query<Category>()
            join p in session.Query<Product>() on e.Id equals p.CategoryId into products
                    select new
                        {
                            Id = c.Id,
                            Name = c.Name,
                            products= products.Select(p => new
                                {
                                    id = p.Id,
                                    Name = p.Name
                                }).ToList()
                        }).ToList();

因此,我只有至少有一种产品(内部联接)的类别。如何使用Product执行左连接?

0 个答案:

没有答案