Thứ Sáu, 27 tháng 11, 2015

Generic Repository in ASPNET5

In this post, I am explaining generic repository pattern using EF7. The Repository Pattern is a common construct to avoid duplication of data access logic throughout our application. The purpose of the repository is to hide the details of accessing the data. We can easily query the repository for data objects, without having to know how to provide things like a connection string. The Repository pattern adds a layer between the data and domain layers of an application. It also makes the data access parts of an application better testable. Here is the initial version of repository interface. Hide   Copy Code 1 public interface IEmployeeRepository 2 { 3 Task<Employee>...
Read More »

Thứ Sáu, 6 tháng 11, 2015

Khắc phục lỗi: system.web.webpages.html.htmlhelper' does not contain a definition for ViewBag...

Một ngày, mở project web MVC bỗng nhiên gặp lỗi: system.web.webpages.html.htmlhelper does not contain a definition for ViewBag... Đây là cách khắc phục: 1. Tắt Visual Studio 2. Xóa hết mọi thứ trong thư mục bin và obj 3. Xóa temporary ASP.NET file trong thư mục: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files 4. Mở visual studio,  đổi sang version chính xác của System.Web.Mvc project, trong web.config ở Views. Vd: <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> ---> Version=5.0.0.0 5. Rebuild solution -> do...
Read More »