[英]How to fill dataset using LINQ with FillDataSet(ds) Method c#
How to fill dataset using LINQ with FillDataSet(ds) Method.如何使用 LINQ 和 FillDataSet(ds) 方法填充数据集。 When iam trying to implement this code iam getting error like FillDataSet does not exist in current context.
当我尝试实现此代码时,我收到错误,例如当前上下文中不存在 FillDataSet。
My code is我的代码是
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;
Please tell me how to fill dataset with FillDataSet(ds) Method.请告诉我如何使用 FillDataSet(ds) 方法填充数据集。 Thank you.
谢谢你。
You don't have to fill a DataSet
with LINQ2SQL.你不必填充
DataSet
与LINQ2SQL。 Nor do you have to use DataTable
etc. All you need is the data context and perform queries on that:您也不必使用
DataTable
等。您只需要数据上下文并对其执行查询:
var query = from product in dtContext.emps
select product;
query
will be of type IQueryable<T>
and you can use eg a foreach
on it to go through its content, or filter it further with a where
clause. query
将是IQueryable<T>
类型,您可以在其上使用例如foreach
来查看其内容,或使用where
子句对其进行进一步过滤。 Why do you want a DataSet
?你为什么需要一个
DataSet
?
From your post从你的帖子
FillDataSet does not exist in current context.
当前上下文中不存在 FillDataSet。
It clearly means that it cant access the FillDataSet method or else your method doesnt exist.这显然意味着它无法访问 FillDataSet 方法,否则您的方法不存在。
If it exists, then try changing the access specifier to public
if it is in different class.如果它存在,然后尝试将访问说明符更改为
public
如果它在不同的类中。
PS: did you declare any method named FillDataSet
? PS:您是否声明了任何名为
FillDataSet
方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.