Reputation: 615
Assuming EF6.1 is in use....
Assuming that 'Category' is a POCO type that EF persists, that 'context' has a DbSet property called 'categories', that 'x' is defined as a legitimate local of type int, and that c.ID is also of type int.....
Given the following expression
context.Categories.Where<Category>((Category c) => {return c.ID == x});
Is there a way, before the query happens, to return the compiled SQL statement as a string without hitting the Database?
Upvotes: 0
Views: 56
Reputation: 12437
public IQueryable<Category> GetCategory(int x)
{
return context.Categories.Where<Category>(c => c.ID == x);
}
To see SQL:
Console.WriteLine(GetCategory(1).ToString());
Upvotes: 1