2
Vote

Nested Any

description

I have a pair of tables, with a 1-many relationship, and a FK defined. The model has navigational properties defined, child.parent and parent.children.

What works, against SQL Server, and doesn't seem to, in Effort:
var result = myDbContext.parents
.Where(p => p.name == "SMITH")
.Where(p => p.children.Any(c => c.age == 10)

comments

tamasflamich wrote Nov 13, 2014 at 6:05 PM

Hello,

Thank you for reporting this issue. Can you provide a detailed description of the issue?

Does it throw an exception? Does the return value differ? Is the name property a fixed length string?

sensoryoverload wrote Jan 20, 2016 at 5:56 AM

I have a very similar problem. If I use the lambda

.Where(crs => crs.Element.MainElementId == _Id)

it does not work in the unit test but works perfectly with SQLServer.

Weird thing is that when I filter on the primary key I do not get an exception:

.Where(crs => crs.Element.Id == _Id)

The transaction will abort after about 10 seconds:

Test Name: CheckUpdateAndPublishClassroomSession
Test FullName: Business.Write.Tests.LearningPaths.Elements.ClassroomSessionTransactionTest.CheckUpdateAndPublishClassroomSession
Test Source: C:\development\Rushmore\dev-2009\Learnlinq\Business.Write.Tests\Transactions\LearningPath\Elements\ClassroomSessionElementTransactionTest.cs : line 276
Test Outcome: Failed
Test Duration: 0:00:18,6312279

Result StackTrace:
bij NMemory.Transactions.Transaction.EnsureTransaction(Transaction& transaction, IDatabase database)
bij NMemory.Tables.Table2.Update(IQueryable1 query, IUpdater1 updater, Transaction transaction)
bij NMemory.Tables.Table
2.NMemory.Tables.IBulkTable<TEntity>.Update(TableQuery1 query, Expression1 updater, Transaction transaction)
bij NMemory.Linq.QueryableEx.Update[T](IQueryable1 queryable, Expression1 updater, Transaction transaction)
bij Effort.Internal.Common.DatabaseReflectionHelper.WrapperMethods.UpdateEntities[TEntity](IQueryable1 query, Expression1 updater, Transaction transaction)
--- End of inner exception stack trace ---
bij System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
bij System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
bij System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
bij Effort.Internal.Common.DatabaseReflectionHelper.UpdateEntities(IQueryable source, Expression updater, Transaction transaction)
bij Effort.Internal.CommandActions.UpdateCommandAction.ExecuteNonQuery(ActionContext context)
bij Effort.Provider.EffortEntityCommand.ExecuteNonQuery()
bij System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext1 c)
bij System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func3 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 executed)
bij System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)
bij System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery()
bij System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary
2 identifierValues, List`1 generatedValues)
bij System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
--- End of inner exception stack trace ---
bij System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
bij System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut)
bij System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func2 updateFunction)
bij System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update()
bij System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__35()
bij System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func
1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
bij System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
bij System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.<SaveChangesInternal>b__27()
bij System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
bij System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
bij System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
bij System.Data.Entity.Internal.InternalContext.SaveChanges()
--- End of inner exception stack trace ---
bij System.Data.Entity.Internal.InternalContext.SaveChanges()
bij System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
bij System.Data.Entity.DbContext.SaveChanges()
bij Learnlinq.Data.Core.DataAccess.DataContextBase.SaveChanges()

Result Message:
Test method Business.Write.Tests.LearningPaths.Elements.ClassroomSessionTransactionTest.CheckUpdateAndPublishClassroomSession threw exception:
System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Reflection.TargetInvocationException: Het doel van een aanroep heeft een uitzondering veroorzaakt. ---> System.Transactions.TransactionAbortedException: De transactie is afgebroken.