【发布时间】:2016-03-07 16:50:19
【问题描述】:
我们将数据存储在 SQLite 数据库中。数据显示在 DevExpress.XtraGrid.GridControl 中。为了获取相关数据,我们创建临时表并填充它。 数据上下文:
public class AccountsSQLiteDataContext : DbContext
{
public AccountsSQLiteDataContext(IDbConnection connection)
: base((SQLiteConnection)connection, false)
{
Database.SetInitializer<AccountsSQLiteDataContext>(null);
}
public DbSet<tmp_acc> TmpAccounts { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
使用 DbContext:
AccountsSQLiteDataContext myContext = new AccountsSQLiteDataContext(myDbConnection);
public IQueryable AccountTable
{
get
{
return myContext.TmpAccounts;
}
}
DevExpress.Data.Linq.LinqServerModeSource myLinqSource = = new DevExpress.Data.Linq.LinqServerModeSource();
myLinqSource.QueryableSource = AccountTable;
myGridControl.DataSource = myLinqSource;
在数据更改后我调用:myLinqSource.Reload();
并不是所有 SQLite 临时表中的数据变化都显示在网格中。添加和删除表行生效。但未显示单元格文本的更改。 过滤器函数对新值生效。见printscreen。在过滤器选项中是正确的值,在网格中是旧值。
如何在临时表更改后刷新存储在 DbContext 中的本地数据以显示正确的值?
【问题讨论】:
-
你在使用 WinForms DataGridView 吗?
-
我们使用 DevExpress UI 框架及其 DevExpress.XtraGrid.GridControl 和 DevExpress.XtraGrid.Views.Grid.GridView。
标签: c# entity-framework sqlite xtragrid