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

Batch Update protected properties and classes

Open dochoffiday opened this issue 6 years ago • 2 comments

Batch Update protected properties and classes

It would be nice to be able to do batch updates on protected (or private) properties and classes.

For example, say we have a Planet entity:

public class Planet
{
    protected Planet() { }
    public string Status { get; protected set; }
}

I would like to run something like this:

respository
    .Query<Planet>()
    .Where(x => x.Status == "LAME")
    .Update(x => new Planet { Status = "AWESOME" });

... but I can't because Planet and Status are inaccessible to their protection level.

reference to stack overflow question: https://stackoverflow.com/questions/58329653/can-i-batch-update-protected-properties-and-classes-using-entity-framework-plus/58340886#58340886

dochoffiday avatar Oct 11 '19 13:10 dochoffiday

Hello @dochoffiday ,

Thank you for reporting, we will look at it very soon to make it works with either a dictionary and/or an anonymous type

respository
    .Query<Planet>()
    .Where(x => x.Status == "LAME")
    .Update(x => new { Status = "AWESOME" });

respository
    .Query<Planet>()
    .Where(x => x.Status == "LAME")
    .Update(dict);

Best Regards,

Jonathan


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

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

JonathanMagnan avatar Oct 11 '19 14:10 JonathanMagnan

Hello @dochoffiday ,

Just to let you know, the feature is now available in EF Extensions. You can now use anonymous type in the UpdateFromQuery part.

We are currently merging both codes (Batch Update from EF Plus and EF Extensions) together. So it should be soon available on EF Plus as well. We try hard to make it happen for next week.

JonathanMagnan avatar Oct 21 '19 18:10 JonathanMagnan