Hi,

We have a strange problem. The scenario is like this.

  • We open a Session
  • We Create a DisconnectedState
  • We do a Connect() on the DisconnectedState
  • All I/O is now running through the DisconnectedState
  • We create a Person
  • We create a New Address Entity
  • We add it to the Person's AddressList using an Add()
  • The AddressList remains empty

In the Attachment you can see the exact spot in our code and the Count.

Regards Paul Sinnema Diartis AG


Updated at 19.08.2010 12:27:46

Funny is that when I use the Debugger to view properties of the AddressList before I add the new Address the result is different. In that case the Count = 1!


Updated at 19.08.2010 12:38:18

We were able to create a work around for this like so:

/// <summary>
    /// Add a new Address item to the AddressList navigation property of the Contact Entity
    /// </summary>
    public Address AddNewAddress(AddressDTO dto)
    { // START add DirectDerivedClasses with arguments
        Address newItem = new Address(dto);
        // TODO: This is a workaround for a DataObjects bug.
        var dummyResult = this.Z_AddressList.ToList();
        if(!this.Z_AddressList.Add(newItem))
        {
            throw new InvalidOperationException("Add");
        }
        newItem.OnInitializing(EntityInitializationMode.Added);
        return newItem;
    } // END add DirectDerivedClasses with arguments

Updated at 19.08.2010 16:07:59

public  partial class Contact : AbstractIntersectingHistory , IComparable
{ // START partial class
    [Field(LazyLoad = true)]
    [Association(OnOwnerRemove = OnRemoveAction.Clear, OnTargetRemove = OnRemoveAction.Clear, PairTo = "Z_Contact")]
    public EntitySet<Address> Z_AddressList { get;  set; }

Updated at 19.08.2010 16:16:24

public  partial class Address : AbstractIntersectingHistory , IComparable
{ // START partial class
    #region DataObjectsFields

    [Field(Nullable = false), FieldMapping("ContactId")]
    [Association(OnOwnerRemove = OnRemoveAction.Clear, OnTargetRemove = OnRemoveAction.Clear)]
    public Contact Z_Contact { get;  set; }

Updated at 20.08.2010 15:25:11

The work around has some bad side-effects. Now sometimes when we add an Entity we get an 'Index out of range' Exception.


Updated at 22.08.2010 12:08:07

Hi Alex,

It happens during the ToList() work arround from above.

Stack trace:

Xtensive.Storage.dll!Xtensive.Storage.EntitySet<Diartis.KLIB.Model.ContactAdditionalInformation>.CopyTo(Diartis.KLIB.Model.ContactAdditionalInformation[] array = {Diartis.KLIB.Model.ContactAdditionalInformation[2]}, int arrayIndex = 3) Line 210 + 0xf5 bytes   C#
mscorlib.dll!System.Collections.Generic.List<Diartis.KLIB.Model.ContactAdditionalInformation>.List(System.Collections.Generic.IEnumerable<Diartis.KLIB.Model.ContactAdditionalInformation> collection) + 0x109 bytes    
System.Core.dll!System.Linq.Enumerable.ToList<Diartis.KLIB.Model.ContactAdditionalInformation>(System.Collections.Generic.IEnumerable<Diartis.KLIB.Model.ContactAdditionalInformation> source) + 0x50 bytes 
KLIBDatabase.dll!Diartis.KLIB.Model.ContactAdditionalInformationTitle.AddNewContactAdditionalInformation(Diartis.KLIB.Model.ContactAdditionalInformationDTO dto = null) Line 542 + 0x20 bytes   C#
KLIBDatabase.dll!Diartis.KLIB.Model.ContactAdditionalInformationTitle.AddNewContactAdditionalInformation() Line 532 + 0xe bytes C#
KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMContactAdditionalInformationTitle.AddNewContactAdditionalInformation() Line 614 + 0x2a bytes C#
KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMContactAdditionalInformationTitle.VMContactAdditionalInformationFactory.Create() Line 90 + 0x23 bytes    C#
KLIBControlLibrary.dll!Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBEditableListView.AddNewItem(bool bringIntoView = true) Line 468 + 0x53 bytes    C#
KLIBControlLibrary.dll!Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBEditableListView.AddEmptyItem(object source = {Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBEditableListView}) Line 122 + 0x14 bytes    C#
KLIBControlLibrary.dll!Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBEditableListView.OnAddItem(object target = {Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBEditableListView}, System.Windows.Input.ExecutedRoutedEventArgs e = {System.Windows.Input.ExecutedRoutedEventArgs}) Line 109 + 0x21 bytes  C#
PresentationCore.dll!System.Windows.Input.CommandBinding.OnExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) + 0xe2 bytes 
PresentationCore.dll!System.Windows.Input.CommandManager.ExecuteCommandBinding(object sender, System.Windows.Input.ExecutedRoutedEventArgs e = {System.Windows.Input.ExecutedRoutedEventArgs}, System.Windows.Input.CommandBinding commandBinding) + 0xd2 bytes 
PresentationCore.dll!System.Windows.Input.CommandManager.FindCommandBinding(System.Windows.Input.CommandBindingCollection commandBindings, object sender, System.Windows.RoutedEventArgs e, System.Windows.Input.ICommand command, bool execute) + 0x100 bytes  
PresentationCore.dll!System.Windows.Input.CommandManager.FindCommandBinding(object sender, System.Windows.RoutedEventArgs e, System.Windows.Input.ICommand command, bool execute) + 0x234 bytes 
PresentationCore.dll!System.Windows.Input.CommandManager.OnExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) + 0x3a bytes 
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x53 bytes  
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) + 0x271 bytes  
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {System.Windows.Controls.Button}, System.Windows.RoutedEventArgs args = {System.Windows.Input.ExecutedRoutedEventArgs}) + 0x14e bytes 
PresentationCore.dll!System.Windows.Input.RoutedCommand.ExecuteImpl(object parameter, System.Windows.IInputElement target, bool userInitiated) + 0x17f bytes    
PresentationFramework.dll!System.Windows.Controls.Button.OnClick() + 0xaf bytes 
PresentationFramework.dll!System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e) + 0x118 bytes  
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x53 bytes  
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) + 0x271 bytes  
PresentationCore.dll!System.Windows.UIElement.ReRaiseEventAs(System.Windows.DependencyObject sender = {System.Windows.Controls.Button}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}, System.Windows.RoutedEvent newEvent) + 0x183 bytes   
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) + 0x53 bytes  
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) + 0x271 bytes  
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender = {System.Windows.Controls.Button}, System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}) + 0x14e bytes    
PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs args = {System.Windows.Input.MouseButtonEventArgs}) + 0x96 bytes 
PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea() + 0x471 bytes   
PresentationCore.dll!System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport inputReport) + 0xfd bytes  
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.ReportInput(System.IntPtr hwnd, System.Windows.Input.InputMode mode, int timestamp, System.Windows.Input.RawMouseActions actions, int x, int y, int wheel) + 0x4f9 bytes 
PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.FilterMessage(System.IntPtr hwnd = 794466, MS.Internal.Interop.WindowMessage msg = WM_LBUTTONUP, System.IntPtr wParam = 0, System.IntPtr lParam = 37684357, ref bool handled = false) + 0x398 bytes  
PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x90 bytes

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Aug 19 '10 at 11:48

Paul%20Sinnema's gravatar image

Paul Sinnema
261888896

edited Sep 06 '10 at 04:52

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Does "Address" type have some property paired to this EntitySet? I'd like to try reproducing it, and this is important.

(Aug 19 '10 at 11:48) Alex Yakunin Alex%20Yakunin's gravatar image

How corresponding part part in "Address" class look like?

(Aug 19 '10 at 11:48) Alex Yakunin Alex%20Yakunin's gravatar image

Clear. I will try to reproduce the bug and notify you about result.

(Aug 19 '10 at 11:48) Alex Yakunin Alex%20Yakunin's gravatar image

Please try to provide a stack trace, if this will appear once more. This should help to find the problem.

(Aug 19 '10 at 11:48) Alex Yakunin Alex%20Yakunin's gravatar image

One Answer:

Well after debugging it together with Alex, the latter found out it was a bug in our code and not DO. The Index out of range, in the between time, has also been solved (for as far as I can judge now). Thanks a lot Alex for taking the time again to help us out.

answered Aug 27 '10 at 13:51

Paul%20Sinnema's gravatar image

Paul Sinnema
261888896

You're welcome :)

(Aug 28 '10 at 08:01) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA