|
楼主 |
发表于 2013-6-22 10:56:22
|
显示全部楼层
问题解决了。最终代码是这样,也开了另一个探究LINQ 的帖子,怎么变更为 已完成?- dtDiffLineNoCommonUse = dasF.Tables[0].Clone();<span style="color:green;">//克隆表结构</span>
-
- <span style="color:#2b91af;">DataTable</span> dtF = dasF.Tables[0];
- <span style="color:#2b91af;">DataTable</span> dtT = dasT.Tables[0];
-
- <span style="color:blue;">var</span> query1 = <span style="color:blue;">from</span> e2 <span style="color:blue;">in</span> dtT.AsEnumerable()
- <span style="color:blue;">select</span> e2.Field<<span style="color:blue;">string</span>>(<span style="color:#a31515;">"PART_NO"</span>);
-
- <span style="color:blue;">var</span> query = <span style="color:blue;">from</span> e1 <span style="color:blue;">in</span> dtF.AsEnumerable()
- <span style="color:blue;">where</span> !(query1).Contains(e1.Field<<span style="color:blue;">string</span>>(<span style="color:#a31515;">"RAW_PN"</span>))
- <span style="color:green;">//join e2 in dtT.AsEnumerable() on e1.Field<string>("RAW_PN") equals e2.Field<string>("PART_NO")</span>
- <span style="color:blue;">select</span> e1;
-
- <span style="color:blue;">foreach</span> (<span style="color:blue;">var</span> r <span style="color:blue;">in</span> query)
- {
- dtDiffLineNoCommonUse.Rows.Add(r.ItemArray);
- }
复制代码 |
|