EntityFramework-Plus icon indicating copy to clipboard operation
EntityFramework-Plus copied to clipboard

Batch Update with Navigation Property does not work

Open psyren89 opened this issue 7 years ago • 3 comments

Using a navigation property does not appear to work:

var foos = context.Foos.Where(f => f.DeletedAt == null);
foos.Update(f => new Foo { Sum = f.Bars.Sum(b => b.Value) });

Produces:

System.Data.SqlClient.SqlException : Incorrect syntax near 'Id'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Z.EntityFramework.Plus.BatchUpdate.Execute[T](IQueryable`1 query, Expression`1 updateFactory)
...

Using EF Core 2.1, MSSQL.

psyren89 avatar Oct 02 '18 00:10 psyren89

Hello @psyren89 ,

Thank you for reporting, we successfully reproduced the issue.

We will look at if that's possible to fix it for EF Core.

Best Regards,

Jonathan


Performance Libraries context.BulkInsert(list, options => options.BatchSize = 1000); Entity Framework ExtensionsEntity Framework ClassicBulk OperationsDapper PlusLinqToSql Plus

Runtime Evaluation Eval.Execute("x + y", new {x = 1, y = 2}); // return 3 C# Eval FunctionSQL Eval Function

JonathanMagnan avatar Oct 02 '18 18:10 JonathanMagnan

I also have this issue. What's the status?

megumus avatar Mar 26 '19 11:03 megumus

Hello @megumus ,

I don't think anything will be done until we completely re-write this feature.

If I remember well, that issue was caused by how EF Core generate the query. Since we don't control how the query is generated, that make it very hard on our side to support all this kind of special scenario.

JonathanMagnan avatar Mar 27 '19 21:03 JonathanMagnan