BindingSource从datagridview更新,但ObjectContext不从绑定源刷新 [英] BindingSource is updated from datagridview but ObjectContext is not refreshed from the binding source
问题描述
有人可以帮我解决这个问题吗。
Can someone please help me with this issue.
我的BindingSource是通过 填充的((IList bindingsource是根据用户在datagridview中所做的更改而更新的)不会从绑定源刷新/更新ObjectContext。因此,对BindContext.SaveChanges()的调用会对数据库执行
无效。
My BindingSource is populated via ((IList the bindingsource is updated from changes made by the user in the datagridview but the ObjectContext is not refreshed/updated from the binding source. So a call to BindContext.SaveChanges() does nothing to the DB.
aspnetAppThemeUserSettingBindingSourceRegisteredApps.DataSource =((
aspnetAppThemeUserSettingBindingSourceRegisteredApps.DataSource = ((
IListSource )results).GetList();
此"结果"是
IQueryable
IQueryable
< AspnetAppThemeUserSetting > GetMyRegisteredApplicationsList()
//列表< AspnetAppThemeUserSetting>结果;
BindContext =
BindContext =
new
ASP_OWNEREntities ( GlobalSettings 。GET_ASPUDS_EntityConnectionString ());
var
results = 来自 i
in BindContext.AspnetAppThemeUserSettings.Include( " AspnetApplicationThemeGroup" )
results = from i in BindContext.AspnetAppThemeUserSettings.Include("AspnetApplicationThemeGroup")
.Include(
" AspnetApplicationTheme" )
"AspnetApplicationTheme")
。包括(
" AspnetApplication" )
"AspnetApplication")
。包括(
" AspnetUser" )
"AspnetUser")
其中 i.AspnetUser.UserName ==
" 3001497"
where i.AspnetUser.UserName == "3001497"
where i.AspnetApplication.AspnetMemberships.Where(oo => oo.IsApproved == 1 && oo.IsLockedOut == 0).Count()
> 0
where i.AspnetApplication.AspnetMemberships.Where(oo => oo.IsApproved == 1 && oo.IsLockedOut == 0).Count() > 0
//执行(System.Data.Objects.MergeOption.AppendOnly); // Objects.Mer.Merge // orderby i.AspnetApplication.ApplicationName
选择 i;
select i;
返回 结果;
< span style ="font-size:x-small">当bindingsource从我的BindContext对象获取其数据时,该对象没有using语句,并且BindContext被声明为form wide。 datagridview将呈现所有行详细信息然后,我对datagrid进行
更改,这些更改很好地反映在我的bindingsource中,但是当我调用BindContext.SaveChanges()时,BindContext不会对数据库进行更新。当我看到调试中的BindContext我可以看到旧值
仍然没有对绑定上下文进行任何更改。
请帮忙。
{
推荐答案
您是否看到引发的任何异常?
Do you see any exception raised?
检查上下文的ObjectStateManager以查看新实例是否已存在。
Check the context's ObjectStateManager to see if a new instance does not already exist.
希望这会有所帮助。
这篇关于BindingSource从datagridview更新,但ObjectContext不从绑定源刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!