NHibernate的一名当然pression可以在选择列表中指定当子查询未与EXISTS介绍 [英] NHibernate one expression can be specified in the select list when the subquery is not introduced with EXISTS

查看:230
本文介绍了NHibernate的一名当然pression可以在选择列表中指定当子查询未与EXISTS介绍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含属性,它是一些其他类的列表类。
 我想这个类映射到可查询的扩展另一个类。

  AutoMappper.CreateMap< D​​epartment1,Department2>()
AutoMapper.CreateMap< Employee1,和Employee2>()
VAR employee1 = _session.Query< Employee1>();
。employee1.Project()到<和Employee2>();

这给错误无法excecute查询只有一个前pression可以在选择列表时,子查询不引入指定的存在。
选择employee1_.Id为col_0_0_,employee1_.Name为col_1_0_,(选择Department1_.Id,Department1_.Name从Department.Department Department1_)从[Emplolyee] col_2_0_。[雇员] Employee1_

由于相同的解决方案适用于可枚举情况
 mapper.Map(employee1);
下面是类。

 公共类Employee1
{
    公众诠释标识{获取;设置;}
    公共字符串名称{;设置;}
    公开名单< D​​epartment1> {获取;设置;}
}公共类Department2
{
    公众诠释标识{获取;设置;}
    公众诠释名称{;设置;}
}公共类和Employee2
{
    公众诠释标识{获取;设置;}
    公共字符串名称{;设置;}
    公开名单< D​​epartment2> {获取;设置;}
}公共类Department1
{
    公众诠释标识{获取;设置;}
    公众诠释名称{;设置;}
}


解决方案

您需要使用NHibernate的4,具有项目嵌套集合一些有限的能力。

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;}
}

解决方案

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

这篇关于NHibernate的一名当然pression可以在选择列表中指定当子查询未与EXISTS介绍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆