좋아, 알아 냈어. MiniProfiler를 지원하기 위해 N-Tier 프로젝트를 설정하는 방법은 다음과 같습니다.
웹 레이어 - MiniProfiler, MiniProfiler.MVC, MiniProfiler.EntityFramework 및 BLL Project에 대한 참조를 추가하십시오. 의 Global.asax에서, EF 프로파일 켜 있는지 확인하십시오 여기
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
// Entity Framework Profiling
MiniProfilerEF.Initialize();
}
은 프로파일로 BLL를 호출하는 컨트롤러의 예입니다
[HttpGet]
public ActionResult Index()
{
var profiler = MiniProfiler.Current;
using (profiler.Step("Web Controller"))
{
Employee bll = new Employee();
int value = bll.GetLastEmployeeID();
}
return View();
}
BLL이 - MiniProfiler과에 대한 참조를 추가 DAL 프로젝트. BLL 메서드는 DAL 메서드를 호출합니다. 여기
는 프로파일과 DAL 칭하는 BLL 방법의 예이다 :
public int GetLastEmployeeID()
{
int result = 0;
var profiler = MiniProfiler.Current;
using (profiler.Step("BLL - GetLastEmployeeID"))
{
EmployeeDAO dao = new EmployeeDAO();
result = dao.GetLastEmployeeID();
}
return result;
}
DAL - MiniProfiler 및 MiniProfiler, EF5 참조를 추가. DAL 메서드는 Linq를 사용하여 데이터베이스를 호출합니다. 예를 들면 다음과 같습니다.
public int GetLastEmployeeID()
{
int id = 0;
using (var context = new CompanyEntities())
{
var lastEmployee = (from e in context.Employees
where e.IsDeleted == false
orderby e.EmployeeID descending
select e).First();
id = lastEmployee.EmployeeID;
}
return id;
}
이 설치 프로그램을 사용하면 웹 사이트의 MiniProfiler에 SQL로 표시된 EF 프로파일 링을 표시 할 수 있습니다.
어떻게 BLL에서 DAL로 통신합니까? 웹 서비스를 통한 것입니까? –
설명이 업데이트되었습니다. 필요한 것이 있으면 알려주세요. – Joshua