开发者

How to create Dataset and fill the dataset in asp.net using Entity Framework

开发者 https://www.devze.com 2023-03-15 20:00 出处:网络
I want fill the dataset in asp.net web applic开发者_JAVA百科ation using Entity Framework. I am not familier with Entity Framework please help me.

I want fill the dataset in asp.net web applic开发者_JAVA百科ation using Entity Framework. I am not familier with Entity Framework please help me.

How to create dataset and how to fill dataset?


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 ..


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);
}


 DataTable dt = new DataTable();
 dt.Columns.Add("ID", typeof(int));
 dt.Columns.Add("Name", typeof(string));
 DataSet ds = new DataSet();
 ds.Tables.Add(dt);


@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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号