Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将Linq parallequery转换为ienumerable时出错_C#_Linq_Linqpad - Fatal编程技术网

C# 将Linq parallequery转换为ienumerable时出错

C# 将Linq parallequery转换为ienumerable时出错,c#,linq,linqpad,C#,Linq,Linqpad,使用Linqpad计算我的查询,在上获取上述错误: (from bp in basepay_records select new { empID = bp.Prep_emp, loc = bp.Prep_loc }).Union ( from ass in emp_assignments select new { empID = ass.Prea_emp, loc = ass.Prea

使用Linqpad计算我的查询,在上获取上述错误:

(from bp in basepay_records
select new { empID = bp.Prep_emp, loc = bp.Prep_loc }).Union
                (
                    from ass in emp_assignments
                    select new { empID = ass.Prea_emp, loc = ass.Prea_loc }
                )
在第一个查询中,我尝试过使用paren和不使用paren,没有区别。此联合是一个更大查询的一部分,它最终将位于连接中使用的子查询中,因此我无法执行常规操作,尽管我将其作为独立查询进行了测试,但失败了,并没有对联合进行定义:

var q1 = from bp in basepay_records select new { empID = bp.Prep_emp, loc = bp.Prep_loc };

var q2 = from ass in emp_assignments select new { empID = ass.Prea_emp, loc = ass.Prea_loc };

q1.Union (q2).Dump ("Union");
我确认所有数据类型都匹配

完整错误消息为:

无法执行文本选择:“System.Linq.IQueryable”不包含“Union”的定义和最佳扩展方法重载“System.Linq.ParallelEnumerable.Union(System.Linq.ParallelQuery,System.Collections.Generic.IEnumerable)”具有一些无效参数

实例参数:无法从“System.Linq.IQueryable”转换为“System.Linq.ParallelQuery”


我现在可以用了。我不得不把它分为两个查询,这看起来很愚蠢,但你看。如果您有更好的方法,请告诉我:

var q1 = from mstr in emp_master_records
                            join loctab in
                                (
                                    from bp in basepay_records
                                    select new { empID = bp.Prep_emp, loc = bp.Prep_loc }
                                )
                            on mstr.Prem_emp equals loctab.empID
                            where mstr.Prem_email.StartsWith("TEST_USER")
                            select loctab.loc;

var q2 = from mstr in emp_master_records
                            join loctab in
                                (
                                    from ass in emp_assignments
                                    select new { empID = ass.Prea_emp, loc = ass.Prea_loc }
                                )
                            on mstr.Prem_emp equals loctab.empID
                            where mstr.Prem_email.StartsWith("GREGORY_RANDALL")
                            select loctab.loc;

q1.Union(q2).Dump ("Union");

您知道具体的错误消息是什么吗。一种可能是empID或loc的类型在每个匿名类型中都不同。例如,一个可能是长的,而另一个是int。什么是basepay_记录?basepay_记录和emp_分配是表。您是否在其中一个对象上调用了
AsParallel
,但在另一个对象上没有调用?