如何使用LINQ与FillDataSet填补数据集(DS)方法C# [英] How to fill dataset using LINQ with FillDataSet(ds) Method c#

查看:288
本文介绍了如何使用LINQ与FillDataSet填补数据集(DS)方法C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用LINQ与FillDataSet(DS)方法来填充数据集。当IAM试图执行这些代码IAM越来越像FillDataSet错误不会在目前的情况下存在。

How to fill dataset using LINQ with FillDataSet(ds) Method. When iam trying to implement this code iam getting error like FillDataSet does not exist in current context.

我的代码是

DataSet ds = new DataSet();
ds.Locale = CultureInfo.InvariantCulture;
FillDataSet(ds);

DataTable products = ds.Tables["emp"];

IEnumerable<DataRow> query =
    from product in dtContext.emps.AsEnumerable()
    select product;

请告诉我如何填写数据集FillDataSet(DS)方法。
谢谢你。

Please tell me how to fill dataset with FillDataSet(ds) Method. Thank you.

推荐答案

您不要的有无的填充的DataSet 与LINQ2SQL。也不是你必须使用数据表等,所有你需要的是数据的情况,以及执行查询:

You don't have to fill a DataSet with LINQ2SQL. Nor do you have to use DataTable etc. All you need is the data context and perform queries on that:

var query = from product in dtContext.emps
            select product;



查询将类型的IQueryable< T> ,你可以使用如一个的foreach 它要经过它的内容,或者用其中,子句进一步过滤。你为什么要一个的DataSet

query will be of type IQueryable<T> and you can use e.g. a foreach on it to go through its content, or filter it further with a where clause. Why do you want a DataSet?

这篇关于如何使用LINQ与FillDataSet填补数据集(DS)方法C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆