dataobjects-net icon indicating copy to clipboard operation
dataobjects-net copied to clipboard

Add support for temporary tables in bulk updates

Open anpv opened this issue 5 years ago • 0 comments

It would be good to use temporary tables in bulk updates.

// Case 1
var ids = Enumerable.Range(1, 100_000).Select(i => (long)i);
session.Query.All<SomeEntity>()
    .Where(c => c.Id.In(ids))
    .Set(c => c.SomeProperty, false)
    .Update();

// Case 2
var q1 = session.Query.All<SomeEntity>().Where(c => c.Id.In(ids));
session.Query.All<SomeEntity>()
    .Where(c => q1.Contains(c))
    .Set(c => c.SomeProperty, false)
    .Update();

// Case 3
var values = Enumerable.Range(1, 10_000).Select(i => $"Value {i}");
var q2 = session.Query.Store(values);
session.Query.All<SomeEntity>()
    .Where(c => q2.Any(v => v == c.Value))
    .Set(c => c.SomeProperty, false)
    .Update();

anpv avatar Apr 23 '20 11:04 anpv