3

I want fill the dataset in asp.net web application using Entity Framework. I am not familier with Entity Framework please help me.

How to create dataset and how to fill dataset?

1
  • 3
    The whole point of EF is that you don't have to deal with DataSet's rows/columns structure, but instead, you get nice .NET objects, properties populated, from your EF code... Commented Jun 25, 2011 at 5:34

4 Answers 4

5

You do not usualy use EF to work with DataSet objects.

If you are interested in the standanrd way of populating DataSet, the following are some articles and tutorials that may help you working with DataSet objects:

Working with Datasets in Visual Studio

HOW TO: Create and Use a Typed DataSet by Using Visual C# .NET

Introduction to strongly Typed Data Sets

The C# Station ADO.NET Tutorial

If you are interested in working with Entity Framework, the following videos set may help:

Practical Entity Framework for C#: Explore Entity Framework

You can always use search engines to further searching for tutorials, guides and samples ..

Sign up to request clarification or add additional context in comments.

5 Comments

And this is related to Entity Framework how? The original question was about filling data sets from Entity Framework...
@marc_s: OPs do not always know what they really needs .. I hope I've put him on the right direction.
I am getting result using linq query.I want to bind this linq query result to the dataset how can i bind linq query result to dataset?
@user737497: You dont need a DataSet to show the data on your UI controls. Why do you want to use DataSet here?
I want Gridview sorting when i click tje gridview header text for that i want need dta set to assign the table to the dataview control
2

you can populate your dataset with the following code snippests this question is already asked on stackoverflow.com and answered

you can find Populate a DataSet using Context - Entity Framework 4 here

so i just copy from there and paste here for you

     DataSet dataSet = new DataSet("myDataSet");
dataSet.Tables.Add(new DataTable());
//Setup the table columns.

foreach (CmsCategory categories in context.spCmsCategoriesReadHierarchy(n,sl,nn))
{
    DataRow row = dataSet.Tables[0].NewRow();
    row["A"] = categories.A;
    row["B"] = categories.B;

    dataSet.Tables[0].Rows.Add(row);
}

4 Comments

WHY on earth would you want to do this?? You already have your nice .NET object - WHY kludge those back into a DataTable/DataRow schema??? That's like 20 steps back in time...
Why I need to use data set because I need sorting the grid when i click header text it should be in asc or desc if it is asc it should goes desc for that i need to use default view for grid so i need to bind linq query result to the data set please help me.....
@user737497: you can achieve this by binding a List<Customer> directly to your grid - there's absolutely no need to convert back to a DataSet/DataTable just for this!! You need to read up more on Entity Framework and how to use it to databind to UI controls....
Ok... is it possible to assign the linq query to a data table
0
 DataTable dt = new DataTable();
 dt.Columns.Add("ID", typeof(int));
 dt.Columns.Add("Name", typeof(string));
 DataSet ds = new DataSet();
 ds.Tables.Add(dt);

Comments

0

@Victor, From looking at the dates, I'm late to the party. If you are reading this now, what these folks are trying to say is that you are mixing technologies unneccessarily. The ADO.Net objects have essentially been replaced by the EntityFramework, beginning in .Net 3.5.

To answer the question posed on 6/25/2011, the actual code would be something like this:

List results = SomeQueryResults.ToList();

And that's about it. Most of the rest of the work is done by the grid. you might have to override the OrderBy() function, but that might be it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.