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

Feature Request BatchInsert

Open neurospeech opened this issue 8 years ago • 2 comments

Similar to BatchUpdate, with little modification, can you please provide support for BatchInsert for following example.

      var emails = db.Emails.AsQueryable();

      db.Contacts
          .Where( x => x.Active && 
               ! emails.Any( er => er.EmailAddress == x.EmailAddress ) ) )
          .Select( x => new Email{
                 EmailAddress = x.EmailAddress,
                 Subject = "Welcome to network !!"
           } ).Insert();

It would be very simple as

      `INSERT INTO [TableName](Columns...)  ... GENERATED SELECT QUERY`

neurospeech avatar Jul 26 '17 08:07 neurospeech

Hello @neurospeech ,

We will investigate this request next week to check if we can easily do it.

Best Regards,

Jonathan

JonathanMagnan avatar Jul 26 '17 11:07 JonathanMagnan

We would love this feature too!

inprotech-dev avatar Oct 16 '18 21:10 inprotech-dev

Any update here? I also wanted to add that on website there is an information about free Batch Insert which redirects to InsertFromQuery (from paid extensions). That is probably an error: image

jakoss avatar Sep 19 '23 13:09 jakoss

Hello @jakoss ,

The InsertFromQuery, UpdateFromQuery, and DeleteFromQuery methods in EF Extensions are FREE. EF Plus has a reference to EF Extensions, so you can already use it as well.

I added a task on my side to make free features as free in their respective documentation.

So, the current issue is already completed.

See an example:

var date = DateTime.Now.AddYears(-2);
context.Customers
    .Where(x => x.IsActive && x.LastLogin < date)
    .InsertFromQuery("bck_Customer", x => new { x.CustomerID, x.Name, x.Email });

Let me know if you have any additional questions.

Best Regards,

Jon

JonathanMagnan avatar Sep 19 '23 16:09 JonathanMagnan

Hello @JonathanMagnan, thanks for the answer!

I read into the whole EF Plus referencing EF Extensions. It all makes perfect sense, but it's tricky to understand for a newcomer (here's me). I had to put in some time to understand the model here. I think that detailing directly on the docs page what's free and what's paid would be of great help here. Because i found the tables with features, but on docs i cannot find those information

jakoss avatar Sep 19 '23 19:09 jakoss

Hello @jakoss ,

That sure is understandable to be a little bit lost in it. I would not either know if InsertFromQuery is indeed free or not with the current state of this page.

That is sure something we will try in the upcoming weeks.

JonathanMagnan avatar Sep 20 '23 14:09 JonathanMagnan