mtanneryd / ef-bulk-operations

Bulk operations for Entity Framework 6
Apache License 2.0
80 stars 30 forks source link

BulkUpdateAll with InsertIfNew - Operand type clash: datetime2 is incompatible with int with EF6 #41

Open bsohi opened 1 year ago

bsohi commented 1 year ago

Hi,

Thanks for the tool. We are heavily using this as we are processing lots of data. We allow user to upload file and process 1000's of records and this tool really help us from performance wise.

While adding new table to support bulk operation, we are stumbled on below error on one of the table, which has 2 columns of datetime2(7) datatype not null. The same operation works for other table which has 3 columns of datetime2(7) data type but 2 of them are nullable.

BulkInsertAll is working fine for the table.

I have tried to re-create EDMX file but still same error.

Operand type clash: datetime2 is incompatible with int\r\nDatabase name 'tempdb' ignored, referencing object in tempdb.\r\nDatabase name 'tempdb' ignored, referencing object in tempdb.

Getting this issue on one other table

Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.\r\nDatabase name 'tempdb' ignored, referencing object in tempdb.\r\nDatabase name 'tempdb' ignored, referencing object in tempdb.

Can you please check if this is issue or i am doing something wrong.

BulkUpdateRequest sbur = new BulkUpdateRequest(); sbur.KeyPropertyNames = keyPropertyNames; sbur.UpdatedPropertyNames = updatePropertyNames; sbur.InsertIfNew = true; sbur.Entities = entities; var sburesponse = _saasDB.BulkUpdateAll(sbur);

Thanks Balwinder

mtanneryd commented 1 year ago

I'll do my best to investigate as soon as possible.

/Måns

Måns Tånneryd Tånneryd IT AB Barrskogsvägen 19 186 53 Vallentuna +46-705140093 https://se.linkedin.com/in/manstanneryd

Den mån 16 okt. 2023 kl 23:29 skrev bsohi @.***>:

Hi,

Thanks for the tool. We are heavily using this as we are processing lots of data. We allow user to upload file and process 1000's of records and this tool really help us from performance wise.

While adding new table to support bulk operation, we are stumbled on below error on one of the table, which has 2 columns of datetime2(7) datatype not null. The same operation works for other table which has 3 columns of datetime2(7) data type but 2 of them are nullable.

BulkInsertAll is working fine for the table.

I have tried to re-create EDMX file but still same error.

Operand type clash: datetime2 is incompatible with int\r\nDatabase name 'tempdb' ignored, referencing object in tempdb.\r\nDatabase name 'tempdb' ignored, referencing object in tempdb.

Can you please check if this is issue or i am doing something wrong.

BulkUpdateRequest sbur = new BulkUpdateRequest(); sbur.KeyPropertyNames = keyPropertyNames; sbur.UpdatedPropertyNames = updatePropertyNames; sbur.InsertIfNew = true; sbur.Entities = entities; var sburesponse = _saasDB.BulkUpdateAll(sbur);

Thanks Balwinder

— Reply to this email directly, view it on GitHub https://github.com/mtanneryd/ef-bulk-operations/issues/41, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2BSRLYPZGT2LCNOW5RFNDX7WRK5AVCNFSM6AAAAAA6C2NC5KVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE2DMMJTGIZTAOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

bsohi commented 6 months ago

Any update on this?

Thanks

bsohi commented 6 months ago

Hi,

Just wondering if columns needed to be in specific order in this case. I tried to add mapping

After debugging through the code, it seems like the order of columns when temp table is generated vs when sqlbulkcopy is different. I am not sure why it is working when using BulkInsert.

Can you please look and see if it is an easy fix for you.

Thanks