Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
250
WinCombo Row Selection Causes Entity Update
posted

Suppose that you have an IBindable Generic.List of Entity Framework Customer Entities that serves as a BindingSource.DataSource and that serves as a WinCombo.DataSource.  If the user selects a WinCombo row that differs from its initial row, the WinCombo attempts to update the 1st row's EF Entity properties with the values of the 2nd row's EF Entity properties. 

This fails because one of the values that it attempts to update is the primary-key CustomerID.  The Customer Entity's { set } for Customer ID throws an error.

But none of this should have happened in the first place.  The user is merely selecting a different row - nothing has been edited - there's no reason to write anything.  I can't set e.Cancel = true w/in the WinCombo_Validating() method because WinCombo is attempting to { set } the CustomerID value BEFORE VALIDATION !

What is up with this wackiness?

Parents
No Data
Reply
  • 250
    posted

    From the Call Stack, it looks like the MS CurrencyManager is interpretating a BindingSource.Position change as a change in record state (see bolded and especially underlined calls):

      System.Data.Entity.dll!System.Data.Objects.EntityEntry.VerifyEntityValueIsEditable(System.Data.Objects.StateManagerTypeMetadata typeMetadata, int ordinal, string memberName) + 0x8e bytes 
      System.Data.Entity.dll!System.Data.Objects.EntityEntry.GetAndValidateChangeMemberInfo(string entityMemberName, object complexObject, string complexObjectMemberName, out System.Data.Objects.StateManagerTypeMetadata typeMetadata = null, out string changingMemberName = null, out object changingObject = null) + 0x189 bytes 
      System.Data.Entity.dll!System.Data.Objects.EntityEntry.EntityMemberChanging(string entityMemberName = "JobReleaseID", object complexObject, string complexObjectMemberName) + 0x38 bytes 
      System.Data.Entity.dll!System.Data.Objects.EntityEntry.EntityMemberChanging(string entityMemberName) + 0x28 bytes 
      System.Data.Entity.dll!System.Data.Objects.ObjectStateEntry.System.Data.Objects.DataClasses.IEntityChangeTracker.EntityMemberChanging(string entityMemberName) + 0xb bytes 
      System.Data.Entity.dll!System.Data.Objects.DataClasses.EntityObject.ReportPropertyChanging(string property) + 0x62 bytes 


    > Durcon.Base.Data.dll!Durcon.Base.Data.JobRelease.JobReleaseID.set(long value = 414262) Line 5612 + 0x11 bytes C#
      [Native to Managed Transition] 
      System.dll!System.SecurityUtils.MethodInfoInvoke(System.Reflection.MethodInfo method, object target, object[] args) + 0x5f bytes 
      System.dll!System.ComponentModel.ReflectPropertyDescriptor.SetValue(object component = {Durcon.Base.Data.JobRelease}, object value = 414262) + 0x11b bytes 
      System.Windows.Forms.dll!System.Windows.Forms.BindToObject.SetValue(object value) + 0x63 bytes 
      System.Windows.Forms.dll!System.Windows.Forms.Binding.PullData(bool reformat, bool force) + 0x159 bytes 
      System.Windows.Forms.dll!System.Windows.Forms.BindingManagerBase.PullData(out bool success = true) + 0x73 bytes 
      System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManager_PullData() + 0x3a bytes 
      System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.EndCurrentEdit() + 0x21 bytes 
      System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordState(int newPosition = 1, bool validating = true, bool endCurrentEdit, bool firePositionChange = true, bool pullData = false) + 0xbc bytes 
      System.Windows.Forms.dll!System.Windows.Forms.CurrencyManager.Position.set(int value) + 0x42 bytes 
      Infragistics2.Win.UltraWinGrid.v10.3.dll!Infragistics.Win.UltraWinGrid.UltraCombo.SyncSelectedRowWithCurrencyManager(bool targetSelectedRow) + 0x114 bytes 
      Infragistics2.Win.UltraWinGrid.v10.3.dll!Infragistics.Win.UltraWinGrid.UltraCombo.SelectedItemChangeHelper(Infragistics.Win.UltraWinGrid.ComboSelectedItemChangeContext context = SelectedIndex, object newData) + 0x9a9 bytes 
      Infragistics2.Win.UltraWinGrid.v10.3.dll!Infragistics.Win.UltraWinGrid.UltraCombo.OnActiveRowChange

    (Infragistics.Win.UltraWinGrid.UltraGridRow newActiveRow, bool scrollIntoView) + 0x8b bytes 
      Infragistics2.Win.UltraWinGrid.v10.3.dll!Infragistics.Win.UltraWinGrid.UltraGridBase.SetActiveRow(Infragistics.Win.UltraWinGrid.UltraGridRow row = {Infragistics.Win.UltraWinGrid.UltraGridRow}, bool scrollIntoView) + 0x1ca bytes 
      Infragistics2.Win.UltraWinGrid.v10.3.dll!Infragistics.Win.UltraWinGrid.UltraGridBase.ActiveRow.set(Infragistics.Win.UltraWinGrid.UltraGridRow value) + 0x23 bytes 
      Infragistics2.Win.UltraWinGrid.v10.3.dll!Infragistics.Win.UltraWinGrid.UltraDropDownBase.Infragistics.Win.ISelectionManager.ActivateItem(Infragistics.Shared.ISelectableItem item) + 0xc0 bytes 
      Infragistics2.Win.v10.3.dll!Infragistics.Win.SelectionStrategySingle.OnMouseDown(Infragistics.Shared.ISelectableItem item = {Infragistics.Win.UltraWinGrid.UltraGridRow}, ref Infragistics.Win.MouseMessageInfo msginfo = {Infragistics.Win.MouseMessageInfo}, bool forceDrag = false) + 0xa5 bytes 
      Infragistics2.Win.v10.3.dll!Infragistics.Win.SelectionStrategySingle.OnMouseDown(Infragistics.Shared.ISelectableItem item = {Infragistics.Win.UltraWinGrid.UltraGridRow}, ref Infragistics.Win.MouseMessageInfo msginfo = {Infragistics.Win.MouseMessageInfo}) + 0x2c bytes 
      Infragistics2.Win.v10.3.dll!Infragistics.Win.SelectionStrategySingle.OnMouseMessage(Infragistics.Shared.ISelectableItem item = {Infragistics.Win.UltraWinGrid.UltraGridRow}, ref Infragistics.Win.MouseMessageInfo msginfo = {Infragistics.Win.MouseMessageInfo}) + 0x3d bytes 
      Infragistics2.Win.v10.3.dll!Infragistics.Win.ControlUIElementBase.ProcessMouseDownHelper(object sender = {Infragistics.Win.UltraWinGrid.ComboDropDownControl}, System.Windows.Forms.MouseEventArgs e = {X = 22 Y = 52 Button = Left}) + 0x732 bytes 
      Infragistics2.Win.v10.3.dll!Infragistics.Win.ControlUIElementBase.ProcessMouseDown(object sender = {Infragistics.Win.UltraWinGrid.ComboDropDownControl},

    ...

Children