将linq查询转换为原始sql

时间:2018-07-10 21:13:24

标签: c# entity-framework linq

我有这个linq查询,我想看看它正在执行的确切选择语句,有人可以告诉我如何将其转换为原始选择语句

var model = DataServiceLocator.GetPMR_DailyReport_DAO()                                           
    .GetAll(Context)                                         
    .Where(x => (x.Report_Writer_ID == currentEmployeeID                                              
    || x.Project.Subdivision.AORs.FirstOrDefault(a => a.Employee_ID == currentEmployeeID && !a.Effective_End_Date.HasValue) != null                                                      
    || x.Project.Customer.AORs.FirstOrDefault(a => a.Employee_ID == currentEmployeeID && !a.Effective_End_Date.HasValue && a.Subdivision == null) != null                                                  
    || ProjectManagementReportPermissions.IsAdministrator)                                                
    && ((x.Report_Details != null && x.Report_Details.Contains(phrase)) || phrase == ""))                                              
    .Select(x => new PMRReportModel
    {
        ID = x.DailyReport_ID,
        Report_Date = x.Report_Date,
        Writer = x.Report_Writer.Employee_LName + ", " + x.Report_Writer.Employee_FName,
        Project_Code = x.Project.Project_Code,
        Project_Name = x.Project.Subdivision.Subdivision_Name,
        Writer_UserName = x.Report_Writer.UserName,
        Writer_ID = x.Report_Writer_ID,
        Delayed = x.Delayed,
        Flagged = x.Flagged,
        Cost_Repair = x.Cost_Repair,
        Report_Details = x.Report_Details
    })                                                 
    .OrderByDescending(x => x.Report_Date)                                               
    .ThenBy(x => x.Writer);

0 个答案:

没有答案