How to fill dataset using LINQ with FillDataSet(ds) Method c#

前端 未结 3 1591
[愿得一人]
[愿得一人] 2021-01-16 17:42

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.

相关标签:
3条回答
  • 2021-01-16 17:43

    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;
    

    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?

    0 讨论(0)
  • 2021-01-16 17:52

    From your post

    FillDataSet does not exist in current context.

    It clearly means that it cant access the FillDataSet method or else your method doesnt exist.

    If it exists, then try changing the access specifier to public if it is in different class.

    PS: did you declare any method named FillDataSet ?

    0 讨论(0)
  • 2021-01-16 17:53

    You have to define your FillDataSet(DatatSet ds) method. Probably you should implement something similar to this example if you are following the MSDN tutorials.

    0 讨论(0)
提交回复
热议问题