locked
save multiple selected datagrid rows to EF table RRS feed

  • Question

  • 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.


    • Edited by zleug Wednesday, September 2, 2020 12:57 PM
    • Moved by CoolDadTx Wednesday, September 2, 2020 3:36 PM WPF related
    Wednesday, September 2, 2020 12:44 PM

All replies

  • Please post questions related to WPF in the Microsoft Q&A forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, September 2, 2020 3:36 PM
  • Hi CoolDadTx. Thanks for reply.

    I just briefly described type of project. My question is:

    How to create method to save multiple selected rows into EF table?

    I didn't see something what is related to WPF.

    Thanks.


    • Edited by zleug Wednesday, September 2, 2020 4:16 PM
    Wednesday, September 2, 2020 4:16 PM