2014-04-07 2 views
1

BLL과 DAL을 사용하는 MVC 4 웹 응용 프로그램이 있습니다. DAL은 EF6과 모델 첫 번째 방법을 사용합니다. MiniProfiler를 설정하여 웹 및 데이터베이스 호출을 프로파일 링하고 싶습니다. MiniProfiler 및 MiniProfiler.MVC4를 Nuget을 통해 추가했으며 웹 사이트에서 실행 중입니다.N 계층 프레임 워크에서 MiniProfiler 사용

제 질문은 쿼리 정보로 EF 호출을 반환하도록 BLL과 DAL을 어떻게 설정할 수 있습니까? - MiniProfiler, MiniProfiler.MVC 및 BLL 프로젝트에 참조

웹 레이어 : 여기

는 프로젝트 설정입니다 방법이다. 컨트롤러는 BLL 메서드를 호출합니다.

BLL - MiniProfiler 및 DAL 프로젝트에 대한 참조. BLL 메서드는 DAL 메서드를 호출합니다.

DAL - MiniProfiler 및 MiniProfiler, EF5에 대한 참조. DAL 메서드는 Linq를 사용하여 데이터베이스를 호출합니다.

해당 설정을 기반으로 BLL에서 MiniProfiler 데이터를 가져올 수 있지만 EF SQL 데이터를 가져 오지 못합니다.

+0

어떻게 BLL에서 DAL로 통신합니까? 웹 서비스를 통한 것입니까? –

+0

설명이 업데이트되었습니다. 필요한 것이 있으면 알려주세요. – Joshua

답변

1

좋아, 알아 냈어. 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 프로파일 링을 표시 할 수 있습니다.

관련 문제