save multiple selected datagrid rows to EF table

  • Thread starter Thread starter zleug
  • Start date Start date
Z

zleug

Guest
Hi All.

My WPF form has DataGrid. The first column is a CheckBox column. I would like when the button is clicked, all row(s) where the CheckBoxes is checked, insert into a EF table. The DataGrid populated by this method.

Public static IEnumerable<EmployeeDepartmentDT> GetEmployeeList(int deptid)
{
using (var context = new Model1())
{
var emplist =
from employee in context.Employees
where !context.EmployeeDepartment.Any(ed => (ed.EmpId == employee.ID) && (ed.DeptId == deptid))
select new EmployeeDepartmentDT
{
EmpName = employee.EmpName,
IsActive = employee.IsActive,
CreatedDate = employee.CreatedDate,
CreatedBy = employee.CreatedBy
};
return emplist.ToArray();
}
}

How to do it? I will appreciate for sample.

Thanks.

Continue reading...
 
Back
Top