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

Feature Request - Insert-Select, Update and Delete with Lambda #6567

Closed
neurospeech opened this issue Sep 18, 2016 · 1 comment
Closed

Feature Request - Insert-Select, Update and Delete with Lambda #6567

neurospeech opened this issue Sep 18, 2016 · 1 comment

Comments

@neurospeech
Copy link

I know EF is good for doing things object model ways, but sometimes bulk operations are very time consuming. I propose following features.

Select Insert
Lets say I want to send message to all customers with certain filter.

   db.Messages.InsertAsync( 
       db.Customers.Where( c=> 
            c.State == State.Active &&
                // note the navigation property
                c.Orders.Any( o=> 
                       o.State == State.Completed &&
                       o.OrderDate > startDate)
            )
            // select some fields...
           .Select(
                c=> new Message{
                     RecipientName = c.Name,
                     Subject = "Your order summary ",
                     Message = $"Thank you so much for your {c.Order
                           s.Count( o => 
                                o.State==State.Completed && 
                                o.OrderDate > startDate)} order(s)."
                }
            ) 
   );

The above query does not return any objects, it simply generates a big INSERT SELECT and executes on the server.

Update/Delete - with Lambda

   db.Customers.DeleteAsync( c=> c.State == State.Inactive &&  !c.Orders.Any());

   db.Customers.UpdateAsync( c=> c.State == State.Inactive &&  c.Orders.Any() )
       .Set( c => new {
             LastCheck = DateTime.UtcNow
        } );
@gdoron
Copy link

gdoron commented Sep 19, 2016

Probably an exact duplicate of #795.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants