简单的帮助(加入表中的错误)如何编码/解决? [英] Simple Help (Errors in Joining Tables) How To Code / Solve?

查看:56
本文介绍了简单的帮助(加入表中的错误)如何编码/解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码:



 名称空间 TA_SCOREBOARD_DATA 
{
public class TA_Scoreboard_Classcs
{

SQL_TA_SCOREBOARDEntities1 contxt = new SQL_TA_SCOREBOARDEntities1();

public List< String> EmployeeAccess2()
{

EmployeeAccess EA = new EmployeeAccess();
View_HCM VH = new View_HCM();

var x = 来自 a in EA
join b VH上a.EmpNo等于b。 EmpNo
选择 new
{
a.EmpNo,
b.EmailAddress
};

return x.ToList();
}
}
}





*我收到这些错误:*



- EA(来自EA):



'无法找到实施方案对于查询模式......'



- x。** ToList **();



'方法'System.Linq ... IEnumerable< tsource>'的类型参数无法从用法中推断出来。尝试明确指定类型参数。'



* WHERE:*



- EmployeeAccess是一个表(带* id *和* EmpNo *列,*带有3个数据的EmpNo *)



- View_HCM是一个视图(带* EmailAddress *,* EmpNo *列和1000多个数据)



- b.EmpNo下没有智能感知



- 使用* edmx ,dbml *对象



- 已经使用System.Data命名空间



我如何内连接根据View_HCM EmpNo使用EmailAddress的EmployeeAccess中的3个EmpNo?

解决方案

 EmployeeAccess EA =  new  EmployeeAccess(); 
View_HCM VH = new View_HCM();





EA和VH是类型( class )。你不能使用linq作为非 IEnumerable 类型。



反而尝试这样..

列表< employeeaccess> EA =  new 列表< employeeaccess>(); < /   employeeaccess  >  < /   employeeaccess  >  


I have this code:

namespace TA_SCOREBOARD_DATA
       {
           public class TA_Scoreboard_Classcs
           {

            SQL_TA_SCOREBOARDEntities1 contxt = new SQL_TA_SCOREBOARDEntities1();

               public List<String> EmployeeAccess2()
               {

                   EmployeeAccess EA = new EmployeeAccess();
                   View_HCM VH = new View_HCM();

                   var x = from a in EA
                           join b in VH on a.EmpNo equals b.EmpNo
                           select new
                           {
                              a.EmpNo,
                              b.EmailAddress
                           };

                    return x.ToList();
               }
           }
       }



*I'm getting these errors under:*

-- EA (from a in EA):

'Could not find an implementation for the query pattern...'

-- x.**ToList**();

'The type arguments for method 'System.Linq...IEnumerable<tsource>' cannot be inferred from the usage. Try specifying the type arguments explicitly.'

*WHERE:*

-- EmployeeAccess is a table (with *id* and *EmpNo* columns, *EmpNo* with 3 data)

-- View_HCM is a view (with *EmailAddress*, *EmpNo* columns and 1000+ data)

-- No IntelliSense under b.EmpNo

-- using *edmx, dbml* objects

-- already using System.Data namespaces

How do I "inner join" the 3 EmpNo in EmployeeAccess according to View_HCM EmpNo with EmailAddress?

解决方案

EmployeeAccess EA = new EmployeeAccess();
  View_HCM VH = new View_HCM();



EA and VH are Types (class). you cannot use linq for a non IEnumerable Types.

instead try like this..

List<employeeaccess> EA = new List<employeeaccess>(); </employeeaccess></employeeaccess>


这篇关于简单的帮助(加入表中的错误)如何编码/解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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