I am working with the Entity Framework model. With the help of LINQ, I am trying to load entities and their associated data in a single query (i.e. to implement eager loading).
Here's the code-behind:
protected void btn5_Click(object sender, EventArgs e)
{
using (EStoreEntities ctx5 = new EStoreEntities())
{
var query = (from o in ctx5.Order_Details.Include("Order") select o);
//Order -navigation property
tb5.Text = (queryas ObjectQuery).ToTraceString();
gv5.DataSource = query;
gv5.DataBind();
}
}
I'm using the following ASP code:
<asp:Button ID="btn5" runat="server" Text="Button" onclick="btn5_Click" />
<asp:GridView ID="gv5" runat="server"></asp:GridView>
<asp:TextBox ID="tb5" runat="server" TextMode="MultiLine"></asp:TextBox>
How do I fix my code to make the Order table content display in my GridView control? Thank you in advance.