• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Display data using entity framework model class

Display data using entity framework model class

Performing the same example by writing code in model class

Sol :-    Create a new view in home folder  (sample)

Creating MODEL CLASS :-

  • Go to solution explorer
  • Go to model folder
  • Double click on account model.c
  • Click on + symbol of model
  • Create a class with name sample model
Public class Sample model ()
{
Public data set ds;
Public sample model ()
{
Sql connection  con = new sql connection (“”);
String s= “select * from emp details “;
Sql data adapter da = new sql data adapter (s, con);
Data set ds = new data set ();
Da.fill (ds,’x’);
}
}

2Go to home controller .cs

Aspired to become an ASP.net ? 
Explore the post to discover the know-hows on ASP.net Training.

2write the following code for action method sample ();

Public action result sample ()
{
Models.sample1 model obj1 = new models.sample1 model ();
List <data row> r = row list <data row> ();
Foreach (Dat row x in obj1.ds.tables [0].Rows)
R .add (x);
View data [‘R’] = R;
Return view ();
}
}
}

2Go to sample 1 .aspx and write the following code:

<% @ import name space = ‘system.data’ %>

<h2>satya technologies </h2>

<div>

<% HTML. Begin form () ; %>

 

2Change the action name in global.aspx and run the application and check.

For indepth understanding click on

 

Summary
Review Date
Reviewed Item
Display data using entity framework model class
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Display data using entity framework model class"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.