linq查询不包含某个值的记录,LINQ查询数据表以检查记录是否存在

I want to perform a LINQ query on a datatable called Records and check if a record exists. If it exists, I want to find out the row which it is in. How might I go about doing this?

I wanted to do a .where on my datatable after adding the system.linq namespace but the method didnt seem to exist. Please advise

P.S : Am using c# in vs 2010

解决方案

You cannot use the method because DataRowCollection doesn't implement IEnumerable. You need to use the AsEnumerable() extension:

var dataRowQuery= myDataTable.AsEnumerable().Where(row => ...

You might also need a project reference to System.Data.DataSetExtensions for this to work.

Good luck!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值