拋出的異常信息爲"New transaction is not allowed because there are other threads running in the session "
可能出現在的情況:
1、在循環中中沒有將對象完全讀入內存,每次只讀取一行,在循環體內執行context.SaveChanges()時拋出異常
解決方法:將objectQuery或objectResut轉換爲List則可,或者在所在修改操作完成後,在循環體後面執行保存。
2、將ObjectQuery直接綁定到數據庫控件後,在修改對象後,執行SaveChanges()拋出異常
解決方法: ObjectResult <Feature> result= _FeatureQuery.Execute(MergeOption.OverwriteChanges);
bindingChrSource.DataSource = result.ToList();