简单的帮助(加入表中的错误)如何编码/解决? [英] Simple Help (Errors in Joining Tables) How To Code / Solve?
问题描述
我有这个代码:
名称空间 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 nonIEnumerable
Types.
instead try like this..
List<employeeaccess> EA = new List<employeeaccess>(); </employeeaccess></employeeaccess>
这篇关于简单的帮助(加入表中的错误)如何编码/解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!