MVC WEB API Get Without Using Entity Framework asp.net c# 4.6

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends welcome to my channel this is Sharon in this video I will show you in my Z without using entity framework how to consume the pan API and here we got the final approach the heterodox horizontal line and the table in Victorville is binder we have implemented to consume web api an MVC without using entity framework that's it if you are a first-time visitor to my channel please subscribe to get the latest updates before writing the coding part in Web API first we'll take the table and the column names the table is an EMP table which contains four columns EMP ID EMP name email and satellite now let's set the coding part for this video tutorial I'm creating a new web API application go to file new project and from the web templates I'm selecting asp.net web application and the dotnet framework am using for punch expire the application name is without entity framework click okay and from the time Rex unselecting bug API click ok and the project is created successfully let's close this default window on the false in this project I'm adding my data source the connection string in the web.config file that's open server Explorer I'll keep the data connections add connection I'm adding my SQL server name after adding a school server name now I'm selecting the database name the database name is a new TV thus connection is succeeded ok ok and he'll got the new DVD beaver is a land under data connections they require this data source of this new DP I click the mouse go to properties and notice in the Providence there is a connection string which contains a data source just copy that whole part over in solution Explorer in the project at the bottom there is a web config file open the one now let's add the connection string there is an already connection string which is a default one let's add a new connection string add name is equals to the connection string name is my connection connection string and pasting the data source which have copied the last one is Howard a name which is a system dot theta dot I still client after adding the connection string in the web config file now open solution Explorer when it's morals folder I'm adding a new class to create the public properties if I click the models folder let's give a meaningful name to the class young big class and here we got our Olympic class now in the CMP class I'm just defining the public of race and our will we have four columns EMP ID aim MP name email and solid let's add four properties first bernisa EMP ID get sad public sing EMP name get set public string email that set the last one is the salary get such after adding the properties open solution explorer now I'm adding the API controller in this controllers folder that will be the controllers add select the controller I'm certain Web API to controller empty and skew the APA control of name EMP is my APA control of me and here we got our API controller which is the EMP firstly a controller I'm adding the name space using consume web api at the project name dot morals after that I want to sit through the data from the database so i'm using the namespace of SQL server using system dot theta dot SQL client using system that data in the last namespace I'm using system not configuration after adding the necessary namespaces now in the API controller I'm adding public I asked it to be action result get EMP is a method now in this method I'm adding list the list the type of element in the list is my class name which is an EMP class let's create an object ac is requested new list EMT class after that let's add the functionality to face the records from the relevance strength SQL main column is an object is equals to configuration manager dot connection strings between double quotes and adding my connection name which is a my connection just copy that one and between the devil quotes dot connector instead of that ESPO connection a spell called is equals to MU SQL connection and this SQL connection I'm Alan Menken after that let's add the SQL query sequence to select stuff I am adding the table name the table name is a DB Odadjian pitch ESCO command Eskil comes an object in u.s. command and this SQL command takes two parameters of us one is a SQL query the command text the second parameter is the SQL connection object which is this one is called semicolon now let us with the data SQL data reader let's create object STR is equals to SQL common dot execute reader method now I'm using my lip to read the data why I'm adding the object easy got add method new Yampa class let's at the properties the MPI D is equals to s gr the SQL data read around to dot get value 0 the item position semicolon and here we got an error cannot implicitly convert the object to end so let's convert typecast that's out come here Liam the name is equals to g r dot that value which is one god crystal method the EMP name is a strange sir I have Erica to string method comma email is equals to h dr dot that value the eye dimensions 3.2 string and the last one is a salary is equals to h dr dot get value the salary is an integer type semicolon friends here the gate value is two and this one is a three in the last step okay I'm adding this object since we how to open here the Pascal connection standard open method that's it they have written the coding part to face the employed details from this EMP table in that EMP controller which is the API controller now we require the URL of this Web API so that's Google Chrome and here we got the output of the cause at the home page now we require the web api of the project after the domain name and having maybe a forward slash let's add the project name which is the EMP of this one and this let's enter and here we got the output of that web api which is an XML file format now let's concerned is very API in MVC switched to the programming part stop debugging open solution Explorer now in the same controllers folder I click the controllers controller and this time I'm selecting a Miss if I can't allow empty the controller name is and here we got our MVC controller now in this controller first let's add the name space consumer appearance this action result in debts I'm adding ienumerable the end remember the out t type I'm adding the Yampa class let's create a altarpieces equals 2 now to consume the web api I am using HTTP client class so we require the limbs best using system the net dot HTTP class now we can access is typically client class it sees an object is equals to new HTTP client it c dot the Pacer does is a property is equals to new uri this your a method takes of property string you are a string so string is a double quotes let's add the web api address at that one semicolon after we got the Web API URL let's consume the web api variable consume the data is equals to exit dot get as a sink within double quotes the string with first URI and requesting this URI EMP don't occur here I empty the controller name consume data dot method so after consume the data I want to display the results very world data will is equals to consume data dot result if data read dot his success status for the data I succeed at the fossil records in declaring a variable results is equals to data rate that content dot read as a Singh I am adding a list in this Eilis I'm adding the last ambient across a result Stockbridge now the final stop let's disappear across the object as we see is equals to a result start result and they reckon you the object EC that said we have consumed the web api in this MVC controller not display recalls require the view page of this action is an index before adding the view page to this project first we must build the application build build solution and here we got a message build succeeded let's close this output message box select the action is an index method I'll click the mouse add view the view now is indexed the template empty and selecting the list template the model class I'm adding my olympic-class this one and the data contacts truss I don't require to add and here we got our index view page now that sends the title of this Windex view without using tentative fella let's add send - I'm closing this center tab after the color of the table and I am deleting this action lens from the table I don't require that edit distant village and also including the create action length let's change the header I'm adding h1 entity framework it's true and this API tutorials after that I'm adding horizontal and that's it without done the complete coding part now before run this application the most important we have to change a controller name open solution Explorer in the project there is an app and score star folder expand that one route config dot CSS file open the lon and notice here the controller is a home which is a default one let's delete that home controller the controller name is EMP display controller copy and the view pairs the action result is index on which is this one that's it we have done the complete coding part it has saved the connection string in the web config file you got the EMP class the API controller MVC controller and the index view pair let's check the results Google Chrome and here we got the final output the heterodox horizontal line and the table EMP table spider we have implemented to consume web api an MVC without using entity framework that's it
Info
Channel: Haritha Computers & Technology
Views: 18,424
Rating: undefined out of 5
Keywords: web api mvc call, consume web api mvc, web api 2 tutorials
Id: EfgSBiZSXAA
Channel Id: undefined
Length: 19min 1sec (1141 seconds)
Published: Sun Jul 07 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.