Attach fails on entities with parent associations

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
mHook
Posts: 6
Joined: Tue 18 Aug 2009 13:01

Attach fails on entities with parent associations

Post by mHook » Tue 01 Sep 2009 10:54

If you have two related entities child and parent then DataContext.Parent.Attach(parentEntity) throws next exception:

Code: Select all

System.Reflection.TargetInvocationException was unhandled
  Message="Exception has been thrown by the target of an invocation."
  Source="mscorlib"
  StackTrace:
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at Devart.Data.Linq.Table`1.a(TEntity A_0, TEntity A_1, Boolean A_2)
       at Devart.Data.Linq.Table`1.Attach(TEntity entity, Boolean asModified)
       at Devart.Data.Linq.Table`1.Attach(TEntity entity)
  InnerException: System.InvalidCastException
       Message="Specified cast is not valid."
       Source="Devart.Data.Linq"
       StackTrace:
            at Devart.Data.Linq.Provider.DeferredQuery`3.a(Object A_0, Boolean A_1)
            at Devart.Data.Linq.Provider.d.SetLinks[TEntity,TCacheEntity,TKey](TEntity obj, Object keySource, IList`1 linkMembers, EntityCache`2 cache, f services, IList`1 queryLoadWith, Dictionary`2 nextLoadWiths)

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 03 Sep 2009 09:45

We have reproduced the problem. I will notify you when it is fixed.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 03 Sep 2009 10:25

The problem is fixed. Look forward to the upcoming new build of dotConnect for MySQL. I will post here when it is available.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 04 Sep 2009 14:44

The new build of dotConnect for MySQL 5.40.42 is available for download now.
It can be downloaded from http://www.devart.com/dotconnect/mysql/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=15739 .

Post Reply