-1

你好这是我的模式 edmx

在此处输入图像描述

我试试这个

protected void Page_Load(object sender, EventArgs e)
    {
         JeansEntities db = new JeansEntities();
         GridView1.DataSource = (db.Employes).Include("Address");
         GridView1.DataBind();
    }

这给了我只是雇员表数据......我不明白......

谢谢

4

1 回答 1

-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();
         }
    }
于 2012-12-12T03:59:51.057 回答