Introduction
This article will give you an understanding of the what and the why of Web API and will demonstrate a CRUD operation with a simple example using Entity Framework and consuming the created service into an ASP.NET MVC application.
The flow of the article
- What is Web API
- Why Web API
- Real-time example of WEB API
- Steps to Create table, Web API Service, and MVC application to consume the service.
- Create a table in SQL Server.
- Create a Data Access Layer in Visual Studio to access the data and perform DB operations.
- Create a Web API project.
- Create an MVC Application to consume Web API Service. Projects created in steps II, III, and IV belong to the same solution.
- Set Project Startup Orde.
- Output Screens
- Conclusion
Web API
- Web API provides service that can be consumed by a broad range of clients like mobile, tablet, desktop, etc.
- The response can be in any format, like XML, JSON (widely used), etc.
- It supports MVC features, like controller, action, routing, etc.
- Supports CRUD operation. CRUD stands for Create, Read, Update, and Delete. It works on HTTP verbs like HttpPost to Create, HttpGet to Read, HttpPut to Update and HttpDelete to Delete.
Why Web API?

Without Web API, the server will have one application to handle the XML request and another application to handle the JSON request, i.e., for each request type, the server will have one application. But with Web API, the server can respond to any request type using a single application. Small end devices like mobile, tablet are capable of handling only the JSON data. So, the Web API has a huge scope to give space in the real world.
A real-time example of WebAPI
- Weather forecasting
- Movie, Bus, Flight booking
There can be one service provider who offers the service and many consumers avail of this service.
Step 1. Create a table in SQL Server.
We will create a table to perform CRUD operation with Web API. The table script is given below.
CREATE TABLE [dbo].[Product](
[ProductId] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
NULL,
[Quantity] [int] NULL,
[Price] [int] NULL
)
Step 2. Create Class Library Project
- New Project -> Visual C# -> Windows -> Class Library Project and name it as DataAccessLayer.
- Right-click on DataAccessLayer project->Add->New Item->Data-> ADO.NET Entity Data Model and name it ShowRoomEF.
- Choose EF designer from the database in the next step.
- Add the table created in step 1 into Entity Framework.

- Create a class called DAL.cs in this project to access the data from DB by Web API service. The code is given below.
DAL.cs
public static class DAL
{
static ShowroomEntities DbContext;
static DAL()
{
DbContext = new ShowroomEntities();
}
public static List<Product> GetAllProducts()
{
return DbContext.Products.ToList();
}
public static Product GetProduct(int productId)
{
return DbContext.Products.Where(p => p.ProductId == productId).FirstOrDefault();
}
public static bool InsertProduct(Product productItem)
{
bool status;
try
{
DbContext.Products.Add(productItem);
DbContext.SaveChanges();
status = true;
}
catch (Exception)
{
status = false;
}
return status;
}
public static bool UpdateProduct(Product productItem)
{
bool status;
try
{
Product prodItem = DbContext.Products.Where(p => p.ProductId == productItem.ProductId).FirstOrDefault();
if (prodItem != null)
{
prodItem.ProductName = productItem.ProductName;
prodItem.Quantity = productItem.Quantity;
prodItem.Price = productItem.Price;
DbContext.SaveChanges();
}
status = true;
}
catch (Exception)
{
status = false;
}
return status;
}
public static bool DeleteProduct(int id)
{
bool status;
try
{
Product prodItem = DbContext.Products.Where(p => p.ProductId == id).FirstOrDefault();
if (prodItem != null)
{
DbContext.Products.Remove(prodItem);
DbContext.SaveChanges();
}
status = true;
}
catch (Exception)
{
status = false;
}
return status;
}
}
Step 3. Create Empty Web API Project.
Navigate as given,
- Select New Project -> Visual C# -> Web -> ASP.NET Web Application and enter your application and solution name.

- Select the empty template from options and check Web API checkbox and click OK.

- The solution will be created as below.

In App_Start -> WebApiConfig.cs file make sure routeTemplate as given below because by default, the route will not have {action}.
In WebApiConfig.cs
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
- Add Reference to the DataAccessLayer project.
- Add the below DLL in references.
- EntityFramework
- SqlServer
- Net.http
- Net.Http.Formatting
- Install Entity Framework from ‘NuGet Package Manager’.
- Create a Model class for the product as below.

Product. cs
namespace WebApiService.Models
{
public class Product
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public int? Quantity { get; set; }
public int? Price { get; set; }
}
}
Copy the connection string from DataAccessLayer -> web. config and paste it in WebApiService -> web. config.
<connectionStrings>
<add name="ShowroomEntities" connectionString="metadata=res://*/ShowRoomEF.csdl|res://*/ShowRoomEF.ssdl|res://*/ShowRoomEF.msl;provider=System.Data.SqlClient;provider connection string="data source=MYSYSTEM\SQLEXPRESS;initial catalog=Showroom;user id=sa;password=xxxxx;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Add Showroom Controller and make a class to inherit from ApiController.
ShowroomController.cs
The Showroom Controller takes care of Inserting, Retrieving, Updating, and Deleting the data in the database. The request comes to this controller from the consuming application.
public class ShowroomController : ApiController
{
// GET: Showroom
[HttpGet]
public JsonResult<List<Models.Product>> GetAllProducts()
{
EntityMapper<DataAccessLayer.Product, Models.Product> mapObj = new EntityMapper<DataAccessLayer.Product, Models.Product>();
List<DataAccessLayer.Product> prodList = DAL.GetAllProducts();
List<Models.Product> products = new List<Models.Product>();
var config = new MapperConfiguration(cfg => cfg.CreateMap<Product, Models.Product>());
var mapper = new Mapper(config);
foreach (var item in prodList)
{
products.Add(mapper.Map<Models.Product>(item));
}
return Json<List<Models.Product>>(products);
}
[HttpGet]
public JsonResult<Models.Product> GetProduct(int id)
{
EntityMapper<DataAccessLayer.Product, Models.Product> mapObj = new EntityMapper<DataAccessLayer.Product, Models.Product>();
DataAccessLayer.Product dalProduct = DAL.GetProduct(id);
Models.Product products = new Models.Product();
var config = new MapperConfiguration(cfg => cfg.CreateMap<Product, Models.Product>());
var mapper = new Mapper(config);
products = mapper.Map<Models.Product>(dalProduct);
return Json<Models.Product>(products);
}
[HttpPost]
public bool InsertProduct(Models.Product product)
{
bool status = false;
if (ModelState.IsValid)
{
EntityMapper<Models.Product, DataAccessLayer.Product> mapObj = new EntityMapper<Models.Product, DataAccessLayer.Product>();
DataAccessLayer.Product productObj = new DataAccessLayer.Product();
var config = new MapperConfiguration(cfg => cfg.CreateMap<Models.Product, Product>());
var mapper = new Mapper(config);
productObj = mapper.Map<Product>(product);
status = DAL.InsertProduct(productObj);
}
return status;
}
[HttpPut]
public bool UpdateProduct(Models.Product product)
{
EntityMapper<Models.Product, DataAccessLayer.Product> mapObj = new EntityMapper<Models.Product, DataAccessLayer.Product>();
DataAccessLayer.Product productObj = new DataAccessLayer.Product();
var config = new MapperConfiguration(cfg => cfg.CreateMap<Models.Product, Product>());
var mapper = new Mapper(config);
productObj = mapper.Map<Product>(product);
var status = DAL.UpdateProduct(productObj);
return status;
}
[HttpDelete]
public bool DeleteProduct(int id)
{
var status = DAL.DeleteProduct(id);
return status;
}
}
Check your service
Execute your service created just now by running the below URL in the browser and changing the port number accordingly.
http://localhost:52956/api/showroom/getallproducts
Service Output

Note. Attached WebApiServiceProvider.zip solution.
since the solution size exceeds the permitted one, have removed the 'packages' folder content of 'WebApiServiceProvider' and kept it in package_content_1.zip and package_content_2.zip.
Kindly don't forget to unzip package_content_1.zip and package_content_2.zip and keep their contents in the 'WebApiServiceProvider\packages' folder. Also, make changes to connection strings accordingly in both the solution.
Step 4. Consuming Web API Service In MVC Application.
- Create an Empty MVC project as below.

- Create a Product model class as created in the WebApiService project.
- Create ServiceRepository.cs in the Repository folder to consume the web API service and create ServiceUrl as a key and as a value in the web. config (port number changes according to the server).
<add key="ServiceUrl" value="http://localhost:52956/"></add> - Add the below DLL in the references.
- Net
- Net.HTTP
- Net.Http.Formatting
ServiceRepository.cs
Service Repository is created to act as a reusable module for requesting, posting, updating, and deleting data in WebAPI. This is used by any action method in the Controller which is created in the next step and avoids duplication of this code.
public class ServiceRepository
{
public HttpClient Client { get; set; }
public ServiceRepository()
{
Client = new HttpClient();
Client.BaseAddress = new Uri(ConfigurationManager.AppSettings["ServiceUrl"].ToString());
}
public HttpResponseMessage GetResponse(string url)
{
return Client.GetAsync(url).Result;
}
public HttpResponseMessage PutResponse(string url, object model)
{
return Client.PutAsJsonAsync(url, model).Result;
}
public HttpResponseMessage PostResponse(string url, object model)
{
return Client.PostAsJsonAsync(url, model).Result;
}
public HttpResponseMessage DeleteResponse(string url)
{
return Client.DeleteAsync(url).Result;
}
}
Create a Controller to handle a request for different action methods and navigate to the corresponding view.
ProductController.cs
The product Controller in the MVC application is created to handle the request received from the user action and to serve the response accordingly. The code for the product controller is given below.
public class ProductController : Controller
{
// GET: Product
public ActionResult GetAllProducts()
{
try
{
ServiceRepository serviceObj = new ServiceRepository();
HttpResponseMessage response = serviceObj.GetResponse("api/showroom/getallproducts");
response.EnsureSuccessStatusCode();
List<Models.Product> products = response.Content.ReadAsAsync<List<Models.Product>>().Result;
ViewBag.Title = "All Products";
return View(products);
}
catch (Exception)
{
throw;
}
}
public ActionResult EditProduct(int id)
{
ServiceRepository serviceObj = new ServiceRepository();
HttpResponseMessage response = serviceObj.GetResponse("api/showroom/GetProduct?id=" + id.ToString());
response.EnsureSuccessStatusCode();
Models.Product products = response.Content.ReadAsAsync<Models.Product>().Result;
ViewBag.Title = "All Products";
return View(products);
}
public ActionResult Update(Models.Product product)
{
ServiceRepository serviceObj = new ServiceRepository();
HttpResponseMessage response = serviceObj.PutResponse("api/showroom/UpdateProduct", product);
response.EnsureSuccessStatusCode();
return RedirectToAction("GetAllProducts");
}
public ActionResult Details(int id)
{
ServiceRepository serviceObj = new ServiceRepository();
HttpResponseMessage response = serviceObj.GetResponse("api/showroom/GetProduct?id=" + id.ToString());
response.EnsureSuccessStatusCode();
Models.Product products = response.Content.ReadAsAsync<Models.Product>().Result;
ViewBag.Title = "All Products";
return View(products);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(Models.Product product)
{
ServiceRepository serviceObj = new ServiceRepository();
HttpResponseMessage response = serviceObj.PostResponse("api/showroom/InsertProduct", product);
response.EnsureSuccessStatusCode();
return RedirectToAction("GetAllProducts");
}
public ActionResult Delete(int id)
{
ServiceRepository serviceObj = new ServiceRepository();
HttpResponseMessage response = serviceObj.DeleteResponse("api/showroom/DeleteProduct?id=" + id.ToString());
response.EnsureSuccessStatusCode();
return RedirectToAction("GetAllProducts");
}
}
Views are created in the ConsumeWebApi MVC application to consume the service.
GetAllProducts.cshtml
.cshtml represents Views (UI) and this View displays all the products available which are received from API calls in the corresponding method.
@model IEnumerable<ConsumeWebApi.Models.Product>
@{
ViewBag.Title = "GetAllProducts";
}
<h2>GetAllProducts</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.ProductName)
</th>
<th>
@Html.DisplayNameFor(model => model.Quantity)
</th>
<th>
@Html.DisplayNameFor(model => model.Price)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.ProductName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Quantity)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>
@Html.ActionLink("Edit", "EditProduct", new { id = item.ProductId, name = item.ProductName, quantity = item.Quantity, prod = item }) |
@Html.ActionLink("Details", "Details", new { id = item.ProductId }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ProductId })
</td>
</tr>
}
</table>
Create. cshtml
This View allows the user to create a product and insert it into the database through a WebAPI call which is done in the corresponding action method.
@model ConsumeWebApi.Models.Product
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Product</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.ProductName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ProductName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ProductName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Quantity, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Quantity, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Quantity, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "GetAllProducts")
</div>
Details. cshtml
This View allows the user to see the particular product through a WebAPI call which is done in the corresponding action method.
@model ConsumeWebApi.Models.Product
@{
ViewBag.Title = "Detail";
}
<h2>Detail</h2>
<div>
<h4>Product</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.ProductName)
</dt>
<dd>
@Html.DisplayFor(model => model.ProductName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Quantity)
</dt>
<dd>
@Html.DisplayFor(model => model.Quantity)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Price)
</dt>
<dd>
@Html.DisplayFor(model => model.Price)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Edit", "EditProduct", new { id = Model.ProductId }) |
@Html.ActionLink("Back to List", "GetAllProducts")
</p>
EditProduct.cshtml
This View allows the user to edit products and update the database through a WebAPI call which is done in the corresponding action method.
@model ConsumeWebApi.Models.Product
@{
ViewBag.Title = "EditProduct";
}
<h2>EditProduct</h2>
@using (Html.BeginForm("Update", "Product", FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Product</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.ProductId)
<div class="form-group">
@Html.LabelFor(model => model.ProductName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ProductName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ProductName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Quantity, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Quantity, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Quantity, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "GetAllProducts")
</div>
Step 5. Set Project Startup Order
- This step is necessary and has to be set up because this solution needs the WebApiService application to keep running and serve the request. The ConsumeWebAPI application will create a request to WebApiService and receive a response back.
- So, in order to make two projects to keep up and running, this step is performed.
- Whereas if WebApiService is hosted in IIS, then only one project that consumes the service can be started, i.e., MVC or Postman.

Output Screens
- Get All Products View.

- Create Product View.

- Edit Product View.

- Detailed View of a product.

- Product table data in Product table of SQL Database.

Conclusion
Web API can be self-hosted (service and consuming application in the same solution) as discussed in this example or it can be deployed on an IIS server. JSON is the widely used request type in services as it is supported by a wide range of client devices. Enjoy creating your own service.

Yves PEMHAPosted Mar 2, 2024, 9:46 PM
Hi Pradeep, thanks for sharing, please can you share the entire projet in Google Drive? My email is [email protected]
Susmita BrahmachariPosted Aug 23, 2021, 2:15 AM
Can you share this crud operation using web api without entity framework
Bhargav somepalliPosted Apr 1, 2021, 12:01 PM
Sir, every thing is fine without any errors but i am getting errors only in views when we used HTML HELPERS, like @html.DisplayFor,EditorFor,LabelFor etc... maybe it might happening because i didnt used data annotations in my model class but i am unaware of that sysntax so can u please provide model class for product in MVC or help me rectify this errors. thank u in advance....
Arul VeluPosted Dec 17, 2020, 7:26 AM
Getting error in EntityMapper that "the type or namespace could not ne found". Is any code avail for this. Waiting fro your reply. Thanks in Advance
Jana SmithPosted Nov 6, 2020, 12:46 PM
You mentioned that you updated your code to use the new version of Automapper. I see where the ShowroomController.cs is different in the downloaded zip version of the WebApiService than in your sample above I was getting a lot of errors using your sample above, and replacing it with the code from the downloaded zip version took care of those errors. However, you do not have sample code for the EntityMapper in this article that I could see. So I'm trying to use what you have in the downloaded zip version, and I'm still getting errors with that - "Mapper does not contain a definition for CreateMap" and "An object reference is required for the non-static field, method, or property Mapper.Map." Would you kind provide the code for the EntityMapper.cs somewhere? Thank you.
Mark TaborPosted Nov 4, 2020, 12:53 AM
Is there anyone who can look into my below error
Mark TaborPosted Nov 4, 2020, 12:48 AM
Getting this error on foreach loop Missing type map configuration or unsupported mapping. Mapping types: Product -> Product DataAccessLayer.Product -> API.Models.Product Destination path: Product Source value: DataAccessLayer.Product
Mark TaborPosted Nov 4, 2020, 12:26 AM
Getting exception on this line Foreach (var item in prodList) { products.Add(mapObj.Translate(item)); } exception is Missing type map configuration or unsupported mapping.
Mark TaborPosted Nov 3, 2020, 11:04 PM
<Message>An error has occurred.</Message><ExceptionMessage>Missing type map configuration or unsupported mapping. Mapping types: Product -> Product DataAccessLayer.Product -> API.Models.Product Destination path: Product Source value: DataAccessLayer.Product</ExceptionMessage> <ExceptionType>AutoMapper.AutoMapperMappingException</ExceptionType>
karunapriya kPosted Apr 30, 2020, 7:51 AM
How to Consume with Windows Services
Andres HIdalgoPosted Mar 25, 2020, 11:32 AM
THere is no ConsumeWebApi project code attached!!!
Desarrollo BIPosted Oct 9, 2019, 4:53 PM
System.Net.Http.HttpRequestException HResult=0x80131500
Desarrollo BIPosted Oct 9, 2019, 4:52 PM
System.Net.Http.HttpRequestException HResult=0x80131500
Andres MataPosted Sep 26, 2019, 9:04 PM
Hey friend did you have the ConsumeWebApi project code for sharing??
Ashutosh RjtPosted Sep 20, 2019, 8:04 AM
What if we have a Product class like below having one more child subclass in it, how to iterate through it? namespace WebApiService.Models { public class Product { public int ProductId { get; set; } public string ProductName { get; set; } public Nullable<int> Quantity { get; set; } public Nullable<int> Price { get; set; } public ProductCompartment prodCompartment {get;set;} } }
Ashutosh RjtPosted Sep 9, 2019, 8:04 AM
EntityMApper.cs file showing exception on this line return Mapper.Map<TDestination>(obj); What is solution for that?
Anchit SoodPosted Jul 21, 2019, 1:03 PM
But there is one problem. When i try to use Create Map using Mapper class, it gives a syntax Error. To overcome that, I had to call Instance method of Mapper class and then pass CreateMap method as param to the Instance method of the class.
Anchit SoodPosted Jul 21, 2019, 1:01 PM
For some reason, the Automapper is not available via Nuget tool bar but I could download it using the Nuget Command line using the command Install-Package AutoMapper -Version 8.1.1 .
Ruwindhu ChandraratnePosted Jun 16, 2019, 9:55 AM
Could you please share the source code through email
Nitesh kumarPosted Jun 16, 2019, 4:38 AM
When run the service then i got error Automap.Automapexception.
Vikas RajputPosted May 24, 2019, 12:57 AM
Nice explanation, just one question what will be your authentication strategy, form based MVC Or token based API ;)
kris amigoPosted Mar 29, 2019, 9:58 AM
Hello, could you please share source code
Omar AlFalahiPosted Mar 28, 2019, 8:05 AM
Hello Pradeep S .. good article you can sent to me source code via email
Hrishikesh BagchiPosted Mar 8, 2019, 12:03 AM
Can you please share the source code as M a beginner and M facing issues with my code.
a kumarPosted Feb 20, 2019, 9:39 PM
What is mean of adding the dll file in the zip folder for download ????
shalindar kumarPosted Dec 19, 2018, 8:52 AM
Nice article, how can download complete source code
Gaurav ChinchankarPosted Dec 17, 2018, 6:49 AM
Pradeep im facing errors while adding enity connection string in webconfig file. Plz can u explain me.
Gaurav ChinchankarPosted Dec 17, 2018, 6:48 AM
Hi men can you plz mail me the source code at [email protected].
Nabeel HassanPosted Nov 15, 2018, 7:34 AM
Bro how can v download source code
Jaimy JohnPosted Sep 18, 2018, 5:25 AM
You can mail me jaimyjohn in gmail.
Jaimy JohnPosted Sep 18, 2018, 5:24 AM
Hi pradeep. I have something to discuss. may i have your contact no or mail id pls.
Tai LePosted Sep 10, 2018, 4:43 AM
Please send link source code to you. Thank you so much
Jhonny MustafaPosted Aug 30, 2018, 1:54 AM
Thanks!! great explanation.
Bogdan NedelcuPosted Aug 1, 2018, 2:02 AM
You have GetProduct method but you don't use it in your Actions. What is the point of having the Where linq method in the following: DbContext.Products.Where(p => p.ProductId == productId).FirstOrDefault(); Just use the predicate from Where method in FirstOrDefault method.
Farhan AhmedPosted Jul 24, 2018, 12:12 AM
Nice explaination
Viknaraj ManogararajahPosted Jul 23, 2018, 11:36 AM
nice article...
Lazy HeapPosted Jul 23, 2018, 4:46 AM
Very well structured and explained basics. Thanks
Ruchi SharavatPosted Jul 23, 2018, 1:56 AM
Very useful and well explained......
Jignesh KumarPosted Jul 22, 2018, 11:28 AM
Its superb and very informative.
Salome NuñezPosted Jul 21, 2018, 2:36 PM
Hi, I have a problem in the definition EntityMapper. I have an error in the constructor entityMapper. Mapper.CreateMap<Models.Product, Product>(); can you please help me. The error is : The name Mapper doesnot exist in the current text. I dont have idea than is it.
Hadshana KamalanathanPosted Jul 20, 2018, 4:04 AM
Nice explanation...
Suraj KumarPosted Jul 19, 2018, 11:37 PM
Very good explanation...