English 中文(简体)
LINQ Over a Dataset Error
原标题:LINQ Over a Dataset Error

我试图通过使用以下代码检索数据组:

    var all_pepole = from rows_of_bank in ds1.Tables[0].Rows select rows_of_bank;
    foreach (System.Data.DataRow row in all_pepole)
    {
        Console.WriteLine("{0} {1} is {2} years old.", row[0].ToString(), row[1].ToString(), row[2].ToString());
    }

但这一法典将给我造成错误,这是错误的:

www.un.org/Depts/DGACM/index_spanish.htm 无法找到对源类型进行查询的模式。 System.Data.DataRowCollection 。 选择没有。 考虑明确标明幅度变量的类型——of_bank

最佳回答

ds1.Tables [0]. Rows为类型<代码>DataRowCollection,实施IE amountableIE amountable<DataRow>。 大多数Linq经营者只从事通用接口。 您可将项目投到<代码>DataRow。 类似:

var all_pepole = from rows_of_bank in ds1.Tables[0].Rows.Cast<DataRow>() select rows_of_bank;

或您可使用<条码> 可计算的延伸方法,从林克延伸至数据基:

var all_pepole = from rows_of_bank in ds1.Tables[0].AsEnumerable() select rows_of_bank;
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签