C# 如何使用包含数据库视图的拖放绑定刷新WPF datagrid?

C# 如何使用包含数据库视图的拖放绑定刷新WPF datagrid?,c#,wpf,database,datagrid,observablecollection,C#,Wpf,Database,Datagrid,Observablecollection,我有以下数据库结构 Table:Books Column: bookid;(PK) Column: book_title; Column: isbn; Column: author_id;(FK) Column: publisher_id;(FK) 上表通过外键与另两个名为“publisher”和“authors”的表连接。它们的定义如下 Table:Publishers Column: publisher_id;(PK) Column: publisher_title; Table:Au

我有以下数据库结构

Table:Books
Column: bookid;(PK)
Column: book_title;
Column: isbn;
Column: author_id;(FK)
Column: publisher_id;(FK)
上表通过外键与另两个名为“publisher”和“authors”的表连接。它们的定义如下

Table:Publishers
Column: publisher_id;(PK)
Column: publisher_title;


Table:Authors
Column: Author_id;(PK)
Column: Author_title;
我创建了数据库视图,它是:

view:book_info
Column: bookid;
Column: book_title;
Column: isbn;
Column: publisher_title;
Column: Author_title;
现在我所做的是,在WPF窗口中拖放这个视图作为datagrid。我获得所需的视图。我尝试在绑定到表的简单网格上使用可观察集合。现在,如何在一个网格上使用这个可观察的集合,该网格的ItemsSource是来自数据库的视图

我还没有写任何代码,因为我仍然不知道如何更新 然后刷新这个网格


事情以意想不到的方式发生了。我的朋友发现即使进行了更新,实体也没有被更新。因此,我们创建了相同的新实体。请参阅下面的代码

//the first declaration on the top.
bookDatabaseEntities bde = new bookDatabaseEntities();

//wrote this code where i need to assign itemssource.This will fetch updates and overwrite older entity created earlier.
bde = new bookDatabaseEntities();
//asssign new view to the grid as itemssource
joinViewsDataGrid.ItemsSource = bde.JoinViews;
这对我来说很有效,对我的案子来说