NHibernate one expression can be specified in the select list when the subquery is not introduced with EXISTS

亡梦爱人 提交于 2019-12-24 00:45:30

问题


I am having class which contain property which is list of some other class. I want to map this class to another class in queryable extension.

AutoMappper.CreateMap<Department1, Department2>()
AutoMapper.CreateMap<Employee1, Employee2>()
var employee1 =_session.Query<Employee1>();
employee1.Project().To<Employee2>(); 

It give error 'Could not excecute query Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.' select employee1_.Id as col_0_0_, employee1_.Name as col_1_0_, (select Department1_.Id, Department1_.Name from Department.Department Department1_) as col_2_0_ from [Emplolyee].[Employee] Employee1_

As same solution works on Enumerable case mapper.Map(employee1); Below are the classes.

public class Employee1
{
    public int Id {get;set;}
    public string Name {get;set;}
    public List<Department1>{get;set;}
}

public class Department2
{
    public int Id {get;set;}
    public int Name {get;set;}
}

public class Employee2
{
    public int Id {get;set;}
    public string Name {get;set;}
    public List<Department2>{get;set;}
}

public class Department1
{
    public int Id {get;set;}
    public int Name {get;set;}
}

回答1:


You need to use NHibernate 4, which has some limited ability to project nested collections.



来源:https://stackoverflow.com/questions/28021423/nhibernate-one-expression-can-be-specified-in-the-select-list-when-the-subquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!