Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update not working with ObjectContext #681

Open
Coder3333 opened this issue Apr 28, 2021 · 2 comments
Open

Update not working with ObjectContext #681

Coder3333 opened this issue Apr 28, 2021 · 2 comments
Assignees

Comments

@Coder3333
Copy link

1. Description

I have a very simple query that uses the old ObjectContext, instead of DbContext, and it fails when I try to perform an Update.

2. Exception

Exception message:
System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.Exception: Oops! A general error has occurred. Please report the issue including the stack trace to our support team: info@zzzprojects.com

Stack trace:
at .[](IQueryable`1 )
   at Z.EntityFramework.Extensions.BatchUpdate.Execute[T](IQueryable`1 query, Expression`1 updateFactory)
   at DbContextExtensions.[](IQueryable`1 , Expression`1 , Action`1 , Boolean )
   at DbContextExtensions.UpdateFromQuery[TEntity](IQueryable`1 query, Expression`1 updateExpression, Action`1 bulkOperationFactory)
   at Z.EntityFramework.Plus.BatchUpdateExtensions.Update[T](IQueryable`1 query, Expression`1 updateFactory, Action`1 batchUpdateBuilder)
   at Z.EntityFramework.Plus.BatchUpdateExtensions.Update[T](IQueryable`1 query, Expression`1 updateFactory)

4. Any further technical details

I have traced the server, and no SQL is being executed.

Z.EntityFramework.Plus.EF6 5.1.31.0

@JonathanMagnan JonathanMagnan self-assigned this Apr 28, 2021
@JonathanMagnan
Copy link
Member

Hello @Coder3333 ,

Thank you for reporting, we will look at it.

Best Regards,

Jon


Sponsorship
Help us improve this library

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

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

@JonathanMagnan
Copy link
Member

Hello @Coder3333 ,

We didn't successfully implement it in our library.

However, we have a public extension method that could help you: GetOrCreateDbContext

Such as:

objectContext.GetOrCreateDbContext().Set<Customer>().Update(x => new Customer {Code = "zzz"});

Let me know if this workaround is working for you.

As you understand, this method returns a DbContext even if you are using purely an ObjectContext.

Best Regards,

Jon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants