0

我更新實體框架(5.0)。我正在使用Linq Method語法來查詢數據庫中的數據。我希望看到在查詢Execution.How時預先加載和延遲加載的區別我可以看到,在Visual Studio 2013年查看實體框架5.0中的查詢執行Visual Studio 2013

+1

你沒有。您可以在SQL分析器中查看它。 – leppie 2014-12-04 07:16:43

+0

它在VS 2013 ..? – Vicky 2014-12-04 07:18:19

+0

不是。它在SSMS中。 – leppie 2014-12-04 07:18:48

回答

1
public async Task<ActionResult> Details(int? id) 
{ 
if (id == null) 
{ 
    return new HttpStatusCodeResult(HttpStatusCode.BadRequest); 
} 

// Commenting out original code to show how to use a raw SQL query. 
//Department department = await db.Departments.FindAsync(id); 

// Create and execute raw SQL query. 
string query = "SELECT * FROM Department WHERE DepartmentID = @p0"; 
Department department = await db.Departments.SqlQuery(query, id).SingleOrDefaultAsync(); 

if (department == null) 
{ 
    return HttpNotFound(); 
} 
return View(department); 

}

去這個鏈接去thorugh這個話題

http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application