我有一个包含属性的类,该属性是其他类的列表。 我想将此类映射到可查询扩展中的另一个类。
AutoMappper.CreateMap<Department1, Department2>()
AutoMapper.CreateMap<Employee1, Employee2>()
var employee1 =_session.Query<Employee1>();
employee1.Project().To<Employee2>();
它给出错误'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_) 作为 col_2_0_ from [Employee].[Employee] Employee1_
因为相同的解决方案适用于可枚举的情况 mapper.Map(employee1); 以下是类。
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;}
}
最佳答案
您需要使用 NHibernate 4,它在投影嵌套集合方面的能力有限。
关于c# - NHibernate 可以在子查询不引入EXISTS时在select list中指定一个表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28021423/