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

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

Open
bsohi opened this issue Oct 16, 2023 · 3 comments

Comments

@bsohi
Copy link

bsohi commented Oct 16, 2023

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
Copy link
Owner

mtanneryd commented Oct 17, 2023 via email

@bsohi
Copy link
Author

bsohi commented May 9, 2024

Any update on this?

Thanks

@bsohi
Copy link
Author

bsohi commented May 9, 2024

Hi,

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

  • in same order as column is defined in database
  • in alphabetical order
  • sending nothing in properties to update collection
    but nothing is working.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants