日期:2014-05-20  浏览次数:20986 次

LINQ to DataSet 连接查询 组合键问题 咨询
SELECT t.id ,
t.name
FROM test AS t JOIN t3 a
ON T.ids = a.ids
AND T.NAME = a.name

 

上面这sql语句我怎么,写成linq?

 

我按下面这写法,编译报错

var q_join___ = from c2 in tb2.AsEnumerable ( )
join c3 in tb3.AsEnumerable ( )
on ( c2.Field<int> ( "ids" ) equals c3.Field<int> ( "ids" ) ) && ( c2.Field<string> ( "Name" ) equals c3.Field<string> ( "Name" ))
select new
{
id = c2.Field<int> ( "ids" ) ,
name = c2.Field<string> ( "Name" )
};


------解决方案--------------------
多个字段 equals 时,需要放到 new { } 里,作为一个匿名类进行 equals