简体   繁体   中英

C# Framework 2 DataTable to IENumerable

I need to convert a DataTable to IEnumerable then use LinqBridge properly... I need to parse a SELECT * FROM X query into a Query.GroupBy(l => l.Field); in order to use some foreach loops correctly grouping my query...

I've tried

public static IEnumerable<DataRow> getRows(DataTable table)
{
    foreach (DataRow row in table.Rows)
    {
        yield return row;
    }
}

But I can't use getRows(myDataTable).Any() or other Linq functions... Some help please.

I can't upgrade from Framework 2, my department wants to downgrade from my 4.0 app to 2.0 because they absoluty deny upgrading the computers, so now I'm very frustrated because my app was WPF 4.0 and I'm migrating everything to WinForm (which is a mess) and updating every method...

Thank you so much.

EDIT

Found the problem, I was calling using LinqBridge but forgot to add after that using System.Linq now the problem is solved and everything working... Delete this post please, or leave it here in order to guide people like me and let them know they need to call System.Linq...

发现问题后,我正在使用LinqBridge进行调用,但后来忘记using System.Linq进行添加,现在问题已解决,并且所有与我在问题中发布的方法一起使用的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM