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

Force output does not work for merge. #563

Open
Alexn opened this issue Dec 15, 2023 · 3 comments
Open

Force output does not work for merge. #563

Alexn opened this issue Dec 15, 2023 · 3 comments
Assignees

Comments

@Alexn
Copy link

Alexn commented Dec 15, 2023

Description

I can't force output for unmodified rows during merge.
My goal is have the same state in memory and database after merge.

Fiddle

https://dotnetfiddle.net/4gUqmr

@JonathanMagnan JonathanMagnan self-assigned this Dec 15, 2023
@JonathanMagnan
Copy link
Member

Hello @Alexn ,

Thank for reporting.

Unfortunately, we don't have any solution at this moment to cover this scenario.

We have the option options.ForceOutputFromUnmodifiedRow = true;, but it currently only works in this 2 scenarios:

We currently have a new method under development that will allow you to read and output values directly into your entities, but it will still take several weeks before we complete it.

Best Regards,

Jon

@Alexn
Copy link
Author

Alexn commented Dec 15, 2023

Hello @JonathanMagnan,

Thanks for answer. I tried to use BulkInsert + InsertIfNotExists, and it does not work as expected.

Could you please look in to the Fiddle, and figure out it?

Fiddle

https://dotnetfiddle.net/IY01fw

@JonathanMagnan
Copy link
Member

JonathanMagnan commented Dec 15, 2023

Hello @Alexn ,

I should have said it in my first answer: you also need to select which properties you want to output.

Here is a working fork from your latest Fiddle: https://dotnetfiddle.net/XvCPIs

context.Set<Customer>().BulkInsert(customers, options => 
{
	//options.ForceSelectOutput = true;
	options.InsertIfNotExists = true;
	options.InsertKeepIdentity = true;
	options.ColumnOutputExpression = x => new { x.Name, x.Email, x.Note, x.Created, x.Updated   };
	options.ForceOutputFromUnmodifiedRow = true;
});

I commented the option options.ForceSelectOutput = true; as it might not do what you think (This option, instead of directly outputting values, it output in a temporary table then select it, which is required in some scenario such as when we cannot automatically discover the table have a trigger)

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

No branches or pull requests

2 participants