Hi,

Allthough we did not issue an ApplyChanges() ourselves, a commit is underway? And it fails. Any ideas?

Regards Paul Sinnema Diartis AG

Exception: Der Transaktionsvorgang kann nicht ausgeführt werden, weil es ausstehende Anforderungen im Rahmen dieser Transaktion gibt. Translation: The Transaktion cannot be executed, because it has pending requests in this transaction.

StackTrace:

System.Data.dll!System.Data.SqlClient.SqlInternalTransaction.Commit() + 0x167 bytes 
    System.Data.dll!System.Data.SqlClient.SqlTransaction.Commit() + 0x144 bytes 
>   Xtensive.Sql.dll!Xtensive.Sql.SqlConnection.Commit() Line 143 + 0x34 bytes  C#
    Xtensive.Storage.Providers.Sql.dll!Xtensive.Storage.Providers.Sql.Driver.CommitTransaction(Xtensive.Storage.Session session, Xtensive.Sql.SqlConnection connection) Line 78 + 0x12 bytes    C#
    Xtensive.Storage.Providers.Sql.dll!Xtensive.Storage.Providers.Sql.SessionHandler.CommitTransaction() Line 127 + 0x35 bytes  C#
    Xtensive.Storage.dll!Xtensive.Storage.Disconnected.DisconnectedSessionHandler.CommitTransaction() Line 65 + 0x22 bytes  C#
    Xtensive.Storage.dll!Xtensive.Storage.Session.CommitTransaction(Xtensive.Storage.Transaction transaction) Line 135 + 0x23 bytes C#
    Xtensive.Storage.dll!Xtensive.Storage.Transaction.Commit() Line 172 + 0x21 bytes    C#
    Xtensive.Storage.dll!Xtensive.Storage.TransactionScope.Dispose() Line 61 + 0x1d bytes   C#
    Xtensive.Storage.dll!Xtensive.Storage.Persistent.LeaveCtorTransactionScope(bool successfully) Line 813 + 0x10 bytes C#
    Xtensive.Storage.dll!Xtensive.Storage.Entity.Entity(Xtensive.Storage.EntityState state) Line 746 + 0xd bytes    C#
    KLIBDatabase.dll!Diartis.KLIB.Model.AbstractEntity.AbstractEntity(Xtensive.Storage.EntityState arg0) + 0x35 bytes   
    KLIBDatabase.dll!Diartis.KLIB.Model.DelictAgeType.DelictAgeType(Xtensive.Storage.EntityState arg0) + 0x35 bytes 
    KLIBDatabase.dll!Diartis.KLIB.Model.DelictAgeType.~Xtensive.Core.Aspects.FactoryMethod(Xtensive.Storage.EntityState arg0) + 0x4a bytes  
    Xtensive.Storage.dll!Xtensive.Storage.Internals.Activator.CreateEntity(System.Type type, Xtensive.Storage.EntityState state) Line 39 + 0x19 bytes   C#
    Xtensive.Storage.dll!Xtensive.Storage.EntityState.Entity.get() Line 97 + 0x3b bytes C#
    Xtensive.Storage.dll!Xtensive.Storage.Linq.Materialization.ItemMaterializationContext.Materialize(int entityIndex, int typeIdIndex, Xtensive.Storage.Model.TypeInfo type, Xtensive.Core.Pair<int>[] entityColumns, Xtensive.Core.Tuples.Tuple tuple) Line 57 + 0x12 bytes   C#
    [Lightweight Function]  
    Xtensive.Core.dll!Xtensive.Core.DelegateBindExtensions.Bind<object[],Xtensive.Core.Tuples.Tuple,Xtensive.Storage.Linq.Materialization.ItemMaterializationContext,Diartis.KLIB.Model.DelictAgeType>.AnonymousMethod__9(Xtensive.Core.Tuples.Tuple arg2, Xtensive.Storage.Linq.Materialization.ItemMaterializationContext arg3) Line 46 + 0x32 bytes  C#
    Xtensive.Storage.dll!Xtensive.Storage.Linq.Materialization.MaterializationHelper.Materialize<Diartis.KLIB.Model.DelictAgeType>.AnonymousMethod__3(Xtensive.Core.Tuples.Tuple tuple) Line 117 + 0x70 bytes   C#
    System.Core.dll!System.Linq.Enumerable.WhereSelectEnumerableIterator<Xtensive.Core.Tuples.Tuple,Diartis.KLIB.Model.DelictAgeType>.MoveNext() + 0xee bytes   
    Xtensive.Core.dll!Xtensive.Core.EnumerableExtensions.Batch<Diartis.KLIB.Model.DelictAgeType>(System.Collections.Generic.IEnumerable<Diartis.KLIB.Model.DelictAgeType> source, int firstFastCount, int initialBatchSize, int maximalBatchSize) Line 498 + 0x1a3 bytes    C#
    Xtensive.Core.dll!Xtensive.Core.EnumerableExtensions.ApplyBeforeAndAfter<Diartis.KLIB.Model.DelictAgeType>(System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<Diartis.KLIB.Model.DelictAgeType>> source, System.Action beforeAction, System.Action afterAction) Line 594 + 0x2f bytes    C#
    Xtensive.Storage.dll!Xtensive.Storage.TransactionalExtensions.ToTransactional<System.Collections.Generic.IEnumerable<Diartis.KLIB.Model.DelictAgeType>>.MoveNext() Line 327 + 0x1e2 bytes   C#
    System.Core.dll!System.Linq.Enumerable.SelectManyIterator<System.Collections.Generic.IEnumerable<Diartis.KLIB.Model.DelictAgeType>,Diartis.KLIB.Model.DelictAgeType>.MoveNext() + 0x242 bytes   
    mscorlib.dll!System.Collections.Generic.List<Diartis.KLIB.Model.DelictAgeType>.List(System.Collections.Generic.IEnumerable<Diartis.KLIB.Model.DelictAgeType> collection) + 0x1d8 bytes  
    System.Core.dll!System.Linq.Enumerable.ToList<Diartis.KLIB.Model.DelictAgeType>(System.Collections.Generic.IEnumerable<Diartis.KLIB.Model.DelictAgeType> source) + 0x50 bytes   
    KLIBDatabase.dll!Diartis.KLIB.Model.DelictAgeType.GetDefaultDelictAgeType(bool mandatory) Line 130 + 0x11 bytes C#
    KLIBDatabase.dll!Diartis.KLIB.Model.DelictAgeType.DefaultOrNull.get() Line 115 + 0x7 bytes  C#
    KLIBDatabase.dll!Diartis.KLIB.Model.Dossier.InitializeMembers(Diartis.KLIB.Model.DossierCreateArguments createArgumentsIn) Line 1060 + 0x13 bytes   C#
    KLIBDatabase.dll!Diartis.KLIB.Model.Dossier.OnInitialize() Line 1036 + 0x16 bytes   C#
    Xtensive.Storage.dll!Xtensive.Storage.Entity.SystemInitialize(bool materialize) Line 478 + 0x1a bytes   C#
    Xtensive.Storage.dll!Xtensive.Storage.Persistent.Initialize(System.Type ctorType) Line 747 + 0x14 bytes C#
    KLIBDatabase.dll!Diartis.KLIB.Model.Dossier.Dossier() Line 1023 + 0x20 bytes    C#
    KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMDossier.CreateDossier() Line 1748 + 0x25 bytes   C#

Updated at 22.07.2010 7:44:32

Hi,

There's definitly something going wrong with transaction handling. This exception is thrown after creating a new Relation for an Organization.

This time we did issue an ApplyChanges().

Regards Paul Sinnema Diartis AG

Exception: A transaction is running, but there should be no active transaction.

StackTrace:

>   Xtensive.Storage.dll!Xtensive.Storage.DisconnectedState.EnsureNoTransaction() Line 511  C#
    Xtensive.Storage.dll!Xtensive.Storage.DisconnectedState.ApplyChanges(Xtensive.Storage.Session targetSession) Line 195 + 0xc bytes   C#
    Xtensive.Storage.dll!Xtensive.Storage.DisconnectedState.ApplyChanges() Line 184 + 0x28 bytes    C#
    KLIBDatabase.dll!Diartis.KLIB.Model.ModelContext.SaveChanges() Line 363 + 0x30 bytes    C#
    KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMContext.SaveChanges() Line 84 + 0x1c bytes   C#
    KLIBBase.dll!Diartis.KLIB.KLIBContext.SaveChanges() Line 289 + 0x21 bytes   C#
    KLIBBase.dll!Diartis.KLIB.KLIBContext.OnSave(object target, System.Windows.Input.ExecutedRoutedEventArgs e) Line 101 + 0x1c 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.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.RoutedEventArgs args) + 0x14e bytes 
    PresentationCore.dll!System.Windows.Input.RoutedCommand.ExecuteImpl(object parameter, System.Windows.IInputElement target, bool userInitiated) + 0x17f bytes    
    KLIBControlLibrary.dll!Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBOverviewControl.ViewItemSelecting(object sender, DevExpress.Xpf.NavBar.NavBarItemSelectingEventArgs e) Line 90 + 0x42 bytes C#
    [Native to Managed Transition]  
    mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) + 0x6f bytes  
    PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) + 0xc3 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.RoutedEventArgs args) + 0x14e bytes 
    DevExpress.Xpf.NavBar.v10.1.dll!DevExpress.Xpf.NavBar.NavBarGroup.CoerceSelectedItemCore(DevExpress.Xpf.NavBar.NavBarItem newItem, DevExpress.Xpf.NavBar.NavBarItem oldItem) + 0x239 bytes  
    DevExpress.Xpf.NavBar.v10.1.dll!DevExpress.Xpf.NavBar.NavBarGroup.CoerceSelectedItem(DevExpress.Xpf.NavBar.NavBarItem newItem) + 0x5a bytes 
    DevExpress.Xpf.NavBar.v10.1.dll!DevExpress.Xpf.NavBar.NavBarGroup.CoerceSelectedItem(System.Windows.DependencyObject d, object value) + 0x5f bytes  
    WindowsBase.dll!System.Windows.DependencyObject.ProcessCoerceValue(System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, ref System.Windows.EntryIndex entryIndex, ref int targetIndex, ref System.Windows.EffectiveValueEntry newEntry, ref System.Windows.EffectiveValueEntry oldEntry, ref object oldValue, object baseValue, object controlValue, System.Windows.CoerceValueCallback coerceValueCallback, bool coerceWithDeferredReference, bool coerceWithCurrentValue, bool skipBaseValueChecks) + 0x109 bytes  
    WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) + 0x93e bytes   
    WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, object value, System.Windows.PropertyMetadata metadata, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType, bool isInternal) + 0x31e bytes  
    WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) + 0xa1 bytes   
    DevExpress.Xpf.NavBar.v10.1.dll!DevExpress.Xpf.NavBar.NavBarGroup.SelectedItem.set(DevExpress.Xpf.NavBar.NavBarItem value) + 0x3f bytes 
    KLIBControlLibrary.dll!Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBNavBarControl.SelectItem(Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBNavBarItem item) Line 22 + 0x17 bytes C#
    KLIBControlLibrary.dll!Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBNavBarControl.SelectItem(object item) Line 36 + 0xf bytes   C#
    KLIBControlLibrary.dll!Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBOverviewControl.AddItem(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs e) Line 369 + 0x26 bytes C#
    KLIBControlLibrary.dll!Diartis.KLIB.KLIBControlLibrary.StandardControls.KLIBOverviewControl.OnListChangedObservable(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs e) Line 321 + 0x11 bytes C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.KLIBEvent<Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs>.Call(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs args) Line 90 + 0x29 bytes  C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.ObservableList<Diartis.KLIB.KLIBViewModel.VMContactRelationRole>.OnListChanged(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs e) Line 322 + 0x3c bytes C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.RelatedList<Diartis.KLIB.KLIBViewModel.VMContactRelationRole,Diartis.KLIB.Model.ContactRelationRole>.OnListChanged(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs e) Line 306 + 0x1a bytes C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.ObservableList<Diartis.KLIB.KLIBViewModel.VMContactRelationRole>.Insert(int index, Diartis.KLIB.KLIBViewModel.VMContactRelationRole item) Line 595 + 0x78 bytes    C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.RelatedList<Diartis.KLIB.KLIBViewModel.VMContactRelationRole,Diartis.KLIB.Model.ContactRelationRole>.AddItems(System.Collections.IList trackedItems, int startIndex) Line 240 + 0xf5 bytes C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.RelatedList<Diartis.KLIB.KLIBViewModel.VMContactRelationRole,Diartis.KLIB.Model.ContactRelationRole>.TrackedListListChanged(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs e) Line 150 + 0x4f bytes    C#
    KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMRelatedEntityList<Diartis.KLIB.KLIBViewModel.VMContactRelationRole,Diartis.KLIB.Model.ContactRelationRole>.TrackedListListChanged(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs e) Line 92 + 0x11 bytes C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.KLIBEvent<Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs>.Call(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs args) Line 90 + 0x29 bytes  C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.ObservableList<Diartis.KLIB.Model.ContactRelationRole>.OnListChanged(object sender, Diartis.KLIB.KLIBLibrary.ObservableListChangedEventArgs e) Line 322 + 0x3c bytes   C#
    KLIBLibrary.dll!Diartis.KLIB.KLIBLibrary.ObservableList<Diartis.KLIB.Model.ContactRelationRole>.Add(Diartis.KLIB.Model.ContactRelationRole item) Line 1070 + 0x93 bytes C#
    KLIBDatabase.dll!Diartis.KLIB.Model.ObservableEntityList<Diartis.KLIB.Model.ContactRelationRole>.EntitySetCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) Line 400 + 0x1c bytes C#
    Xtensive.Storage.dll!Xtensive.Storage.EntitySetBase.NotifyCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedAction action, Xtensive.Storage.Entity item) Line 332 + 0x84 bytes    C#
    Xtensive.Storage.dll!Xtensive.Storage.EntitySetBase.SystemAdd(Xtensive.Storage.Entity item) Line 207 + 0x17 bytes   C#
    Xtensive.Storage.dll!Xtensive.Storage.EntitySetBase.Add(Xtensive.Storage.Entity item, Xtensive.Storage.PairIntegrity.SyncContext syncContext) Line 442 + 0x14 bytes C#
    Xtensive.Storage.dll!Xtensive.Storage.EntitySetBase.Add(Xtensive.Storage.Entity item) Line 400 + 0x10 bytes C#
    Xtensive.Storage.dll!Xtensive.Storage.EntitySetBase.Add(Xtensive.Storage.IEntity item) Line 513 + 0x28 bytes    C#
    Xtensive.Storage.dll!Xtensive.Storage.EntitySet<Diartis.KLIB.Model.ContactRelationRole>.Add(Diartis.KLIB.Model.ContactRelationRole item) Line 100 + 0x19 bytes  C#
    KLIBDatabase.dll!Diartis.KLIB.Model.Contact.AddContactRelationRole(Diartis.KLIB.Model.ContactRelationRoleCreateArguments createArguments) Line 809 + 0x21 bytes C#
    KLIBDatabase.dll!Diartis.KLIB.Model.Contact.AddContactRelationRole() Line 800 + 0xb bytes   C#
    KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMContact.AddNewContactRelationRole() Line 1104 + 0x23 bytes   C#
    KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMContact.VMContactContactRelationRoleFactory.Create() Line 1114 + 0x20 bytes  C#
    KLIBMasksContact.dll!Diartis.KLIB.Masks.Organization.KLIBOrganizationMainPanel.OnNewContactRelationRole(object target, System.Windows.Input.ExecutedRoutedEventArgs e) Line 50 + 0x14 bytes C#

Updated at 22.07.2010 8:44:15

The second case is not a bug: ApplyChanges call is "induced" by your event chain, but it can be executed only when all transactions (all = nested + outermost) created after attachment are closed. So here you should simply ensure it isn't called in this case - i.e. you must postpone this operation until all transactions are closed. Thinking about the first case...

I'm not so shure. We don't open Transactions ourselves.

During our AddContactRelationRole() it seems that a Transaction is opened. Possibly by PostSharp injected code. Below you see the stack at the moment the TransAction is opened in DO's Xtensive.Transaction.Begin(...) method. In the code snippet below you can see what Reflector discovers in our method. We realy don't want to open a Transaction when Adding an Entity to a list.

Regards Paul Sinnema Diartis AG

Xtensive.Storage.dll!Xtensive.Storage.Transaction.Begin() Line 157  C#
    Xtensive.Storage.dll!Xtensive.Storage.Session.OpenTransactionScope(Xtensive.Storage.Transaction transaction) Line 254 + 0x18 bytes  C#
    Xtensive.Storage.dll!Xtensive.Storage.Session.CreateOutermostTransaction(System.Transactions.IsolationLevel isolationLevel) Line 239 + 0xf bytes    C#
    Xtensive.Storage.dll!Xtensive.Storage.Session.OpenTransaction(Xtensive.Storage.TransactionOpenMode mode, System.Transactions.IsolationLevel isolationLevel) Line 73 + 0x4b bytes    C#
    Xtensive.Storage.dll!Xtensive.Storage.Transaction.Open(Xtensive.Storage.Session session, Xtensive.Storage.TransactionOpenMode mode) Line 119 + 0x1c bytes   C#
    Xtensive.Storage.dll!Xtensive.Storage.TransactionalAttribute.OnEntry(PostSharp.Aspects.MethodExecutionArgs args) Line 165 + 0x35 bytes  C#
>   KLIBDatabase.dll!Diartis.KLIB.Model.Contact.AddContactRelationRole() Line 799 + 0x47 bytes  C#
    KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMContact.AddNewContactRelationRole() Line 1104 + 0x23 bytes   C#
    KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMContact.VMContactContactRelationRoleFactory.Create() Line 1114 + 0x20 bytes  C#
    KLIBMasksContact.dll!Diartis.KLIB.Masks.Person.KLIBPersonMainPanel.OnNewContactRelationRole(object target, System.Windows.Input.ExecutedRoutedEventArgs e) Line 51 + 0x14 bytes C#

public ContactRelationRole AddContactRelationRole()
{
    ContactRelationRole CS$1$1__returnValue;
    MethodExecutionArgs CS$0$2__aspectArgs = new MethodExecutionArgs(this, null);
    <>z__Aspects.a3607.OnEntry(CS$0$2__aspectArgs);
    try
    {
        ContactRelationRole CS$1$0000 = this.AddContactRelationRole(null);
        CS$1$1__returnValue = CS$1$0000;
        <>z__Aspects.a3607.OnSuccess(CS$0$2__aspectArgs);
    }
    finally
    {
        <>z__Aspects.a3607.OnExit(CS$0$2__aspectArgs);
    }
    return CS$1$1__returnValue;
}

Updated at 22.07.2010 11:34:07

Ok, That's a concept we've not yet seen.

You're right. We call the SaveChanges() (ApplyChanges()) from the View at the moment a new Entity is added to the NavBar control. This happens during the Add() to the List. The EntitySet probably raises an event the moment the list changes and that causes the chain to become active.

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

asked Jul 22 '10 at 07:35

Paul%20Sinnema's gravatar image

Paul Sinnema
261888896


One Answer:

The second case is not a bug: ApplyChanges call is "induced" by your event chain, but it can be executed only when all transactions (all = nested + outermost) created after attachment are closed.

So here you should simply ensure it isn't called in this case - i.e. you must postpone this operation until all transactions are closed.

Thinking about the first case...


I'm thinking: most of bugs I fixed for you recently are related to events. This part of DO is almost untested: there are tests raising the events, but nothing more. Although problems appear when various data modifications occur inside event handlers.

But I hope the end is near :) + Until now all the scenarios were fully clear for me.


Transactions are really created by PostSharp aspects there, but disabling them is actually a bad idea:

  • If DisconnectedState is attached, they're "virtual" (i.e. they don't propagate to storage).

  • Transactions are used as mechanism allowing to safely undo any changes in case of error. In fact, they mark the boundaries of operation that must be either fully completed or fully rolled back. That's why we keep the state separated from entities - in fact, we just discard a "layer" if data in case of rollback.

Read about automatic transactions in Manual. The conception is described there.

You can apply [NonTransactional] attribute to disable auto transactions for the whole method. But as I said, this is wrong in this case. Instead, you should ensure ApplyChanges is called after completion of property setter. Just think what you're really trying to do: not every expected event is raised at that point, since we haven't eft the topmost method body. So may be you're trying to apply partially updated state; moreover, since transaction isn't yet completed, OnTransactionCommit\Complete* events aren't raised as well, but there can be version updates, logging, validation, etc. So it's quite unsafe point for ApplyChanges.

Speaking differently, it's better to think you can't call ApplyChanges while you're inside any method of any ISessionBound object belonging to Session with this DisconnectedState attached. You should leave any of such methods first.

answered Jul 22 '10 at 07:57

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

I'm trying to reproduce the first case locally. Possibly, there is a bug.

(Jul 22 '10 at 07:57) 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