zzzprojects / EntityFramework-Extensions

Entity Framework Bulk Operations | Improve Entity Framework performance with Bulk SaveChanges, Insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL and SQLite.
https://entityframework-extensions.net
346 stars 57 forks source link

I'd like to know how many rows inserted successfully from server #429

Closed SamuelPark closed 3 years ago

SamuelPark commented 3 years ago

Description

I got zero All RowsAffected values from resultInfo during bulk insert I'd like to know how many rows inserted successfully from server.

        var sb = new StringBuilder();
        var resultInfo = new Z.BulkOperations.ResultInfo();

        try
        {               
            _context.BulkInsert<PBSBATCHFILEDATA>(datas[dataid], options =>
            {
                options.UseRowsAffected = true;
                options.ResultInfo = resultInfo;
                options.Log = s => sb.AppendLine(s);
            });

            _log.LogInformation($" Log {sb.ToString()} ");
            _log.LogInformation($" RowAffected { resultInfo.RowsAffected} ");

        } catch (Exception ee)
        {
            _log.LogError($"Bulk Insert Error {ee.Message}");
        }

Log Result


-- Executing Command:
INSERT  INTO "xx"."xx_BATCH_FILE_DATA" ("BAS_DT", "PBS_TRUS_BNK_CD", "PBS_TRUS_TG_ID", "REC_NO", "SRNO", "DATA_TG_CN", "OPRT_DTTM") VALUES(:P_0, :P_1, :P_2, :P_3, :P_4, :P_5, :P_6)
-- :P_0: System.Object[] (Type = String, Size = 8)
-- :P_1: System.Object[] (Type = String, Size = 10)
-- :P_2: System.Object[] (Type = String, Size = 50)
-- :P_3: System.Object[] (Type = Int32, Size = 22)
-- :P_4: System.Object[] (Type = Int32, Size = 22)
-- :P_5: System.Object[] (Type = String, Size = 2000)
-- :P_6: System.Object[] (Type = Date, Size = 7)
-- CommandTimeout:120
-- Executing at 2021-08-03 오후 6:27:31

-- Completed at 2021-08-03 오후 6:27:31
-- Result: 1054

2021-08-03 18:27:31 [INFO]<1> [XXX]  RowAffected 0 

Further technical details

JonathanMagnan commented 3 years ago

Hello @SamuelPark ,

We will look at it.

I believe Oracle is the only provider which still doesn't support this feature (everything is always harder in Oracle!).

Best Regards,

Jon

JonathanMagnan commented 3 years ago

Hello @SamuelPark ,

Sorry for the delay,

The v3.2.8 has been released. Could you try it and let us know if everything is now working?

Best Regards,

Jon