您好我的架构edmx
我试试这个
protected void Page_Load(object sender, EventArgs e)
{
JeansEntities db = new JeansEntities();
GridView1.DataSource = (db.Employes).Include("Address");
GridView1.DataBind();
}
这只给我Employe表数据...... 我不明白......
谢谢
答案 0 :(得分:-1)
protected void Page_Load(object sender, EventArgs e)
{
using (JeansEntities db = new JeansEntities())
{
GridView1.DataSource = db.Employes.Select(p=> new { Id = p.Id, FirstName = p.FirstName, LastName = p.LastName, Street = p.Address.Street, Number = p.Address.Number, Country = p.Address.Country, Quarter = p.Address.Quarter }).ToList();
GridView1.DataBind();
}
}