I am learning Entity Framework (5.0 and VSExpress 2012), and I am having real problems binding my request to dataGridView in WinForms. I have the code below and it shows my query in the order when I run the application, but I do not know what I need to do to update the dataGridView after changing the data in the base database. What is the best way to do this? What am I doing wrong here?
private void Form1_Load(object sender, EventArgs e) { using( var ctx = new TimeKeepEntities()) { var qLoggedIn = from r in ctx.tblTimeRecords where (r.tblEmployee.Active && !r.ClockOut.HasValue) || System.Data.Objects.EntityFunctions.DiffDays(r.ClockOut, DateTime.Now)<30 select new { Name = r.tblEmployee.Last + ", " + r.tblEmployee.First, r.tblProject.ProjName, r.ClockIn, r.ClockOut }; dataGridView1.DataSource = qLoggedIn.ToList(); } }
source share