Vicky
Vicky

Reputation: 829

View the Query Execution in Entity Framework 5.0 Visual studio 2013

I'm newer to Entity Framework (5.0). I'm using Linq Method syntax to Querying the data from database. I Want to see the Difference between Eager Loading and Lazy loading at the time of Query Execution.How can i see that in Visual Studio 2013.

Upvotes: 0

Views: 259

Answers (1)

user2801771
user2801771

Reputation:

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);

}

go to this link go thorugh this topic

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

Upvotes: 1

Related Questions