세 개의 datagridviews (Department, Employee, EmployeeNotInDepartment)가 있습니다. DataRelations (아래 참조)를 기반으로 Department 및 Employee datagridview를 채 웁니다. EmployeeNotInDepartment datagridview를 채울 수있는 쉬운 방법이 있어야한다고 생각합니다. 어떤 아이디어? 나는 linq을 사용할 필요가 없길 바래.DataTables DataRelation 반대 오른쪽 외부 조인
public Form1()
{
InitializeComponent();
dtDepartment = FillDepartmentList();
dtEmployee = FillEmployeeList();
dsDepartmentEmployees = new DataSet();
// Add tables to dataset
dsDepartmentEmployees.Tables.Add(dtDepartment);
dsDepartmentEmployees.Tables.Add(dtEmployee);
// Create table relationship
dsDepartmentEmployees.Relations.Add("DepartEmpRelation", dtDepartment.Columns["DepartmentNumber"], dtEmployee.Columns["DepartmentNumber"],true);
BindingSource bsDepartment = new BindingSource();
bsDepartment.DataSource = dsDepartmentEmployees;
bsDepartment.DataMember = "table1";
BindingSource bsEmployee = new BindingSource();
bsEmployee.DataSource = bsDepartment;
bsEmployee.DataMember = "DepartEmpRelation";
dataGridView1.DataSource = bsDepartment;
dataGridView2.DataSource = bsEmployee;
}
linq를 사용하지 않는 구체적인 이유는 무엇입니까? 그것은 당신을위한 모든 관계를 관리합니다. – AlwaysAProgrammer
나는 linq를 사용하여 그것을하는 방법을 알고 있지만 Dataset 관계를 사용하여 분명히 간단한 방법이 있는지 궁금합니다. 이 방법에 대한 문서를 찾을 수 없습니다. –