C# 绑定与ORM关联的两个BindingSource

C# 绑定与ORM关联的两个BindingSource,c#,entity-framework,data-binding,C#,Entity Framework,Data Binding,我有DataGridView的表单。 此datagrid使用此绑定: clientBindingSource.DataSource = from asd in db.Clients select new MainGridHelper() { Client = asd }; MainGridHelper有一些属性和有用的方法。但是我从另一个表单添加了新的客户端: _client = n

我有DataGridView的表单。 此datagrid使用此绑定:

        clientBindingSource.DataSource = from asd in db.Clients select new MainGridHelper()
            {
                Client = asd
            };
MainGridHelper有一些属性和有用的方法。但是我从另一个表单添加了新的客户端:

        _client = new Client();
        clientBindingSource.DataSource = _client;
        //...
        DBContext.Clients.InsertOnSubmit(_client);
        DBContext.SubmitChanges();
因此,我在添加客户端之后使用DataGridView.Refresh()。 我在第一个BindingSource中有一个新的空客户机,但添加了行(空单元格)。 我不想合并MainGridHelper和Client类。 如何在没有新的LINQ查询的情况下修复此问题


抱歉,如果这是一个简单的问题。

如果我正确理解您的问题(这是一个很大的if),只需调整原始LINQ查询以排除空值:

clientBindingSource.DataSource = from asd in db.Clients 
                                 where asd != null
                                 select new MainGridHelper()
        {
            Client = asd
        };

第一个bindingSource用于主窗体,第二个用于子窗体。;)所以,clientBindingSource.Insert(new MainGridHelper{Client=_returned})很好地工作了。您到底希望发生什么事情,以及这与现在发生的事情有什么不同?我希望在添加客户端的新实例之后正确地创建新的行,现在我有了带有空单元格的新行。如果我重新运行应用程序,则所有行都已更正。