protected void Page_Load(object sender, EventArgs e) { AdventureWorks_DataEntities adventureWorks_DataEntities = new AdventureWorks_DataEntities(); var query = from emp in adventureWorks_DataEntities.Employees select emp; GridView1.DataSource = query; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AdventureWorks_DataEntities adventureWorks_DataEntities = new AdventureWorks_DataEntities(); foreach (var employee in adventureWorks_DataEntities.Employee) { ListItem li = new ListItem(); li.Text = employee.EmployeeID + " "; if (!employee.EmployeePayHistory.IsLoaded) { employee.EmployeePayHistory.Load(); } foreach (var pay in employee.EmployeePayHistory) { li.Text += "Pay Rate: " + pay.Rate + " "; } BulletedList1.Items.Add(li); } }