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

.NET 9 - BulkInsertOrUpdateOrDeleteAsync - Cannot get _selectExpression #1620

Closed
evicio1 opened this issue Nov 26, 2024 · 4 comments
Closed

Comments

@evicio1
Copy link

evicio1 commented Nov 26, 2024

After upgrading to.NET 9, The following error comes up with BulkInsertOrUpdateOrDeleteAsync

Message

Cannot get _selectExpression

StackTrace

at EFCore.BulkExtensions.IQueryableExtensions.ToParametrizedSql(IQueryable query) at EFCore.BulkExtensions.BatchUtil.GetBatchSql(IQueryable query, DbContext context, Boolean isUpdate) at EFCore.BulkExtensions.SqlAdapters.SqlQueryBuilder.MergeTable[T](DbContext context, TableInfo tableInfo, OperationType operationType, IEnumerable1 entityPropertyWithDefaultValue)
at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.d__91.MoveNext() at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.<MergeAsync>d__91.MoveNext()
at EFCore.BulkExtensions.SqlAdapters.SqlServer.SqlServerAdapter.d__81.MoveNext() at EFCore.BulkExtensions.SqlBulkOperation.<MergeAsync>d__51.MoveNext()
at EFCore.BulkExtensions.DbContextBulkTransaction.d__11.MoveNext()

@borisdj
Copy link
Owner

borisdj commented Nov 26, 2024

It is not yet fully supported, waiting for Pomelo nuget dependency to release v9.
Excepting it to be this week, if not will try to update other packages and only MySql to prerelease.
Dupe of #1605

@borisdj borisdj closed this as completed Nov 26, 2024
@svenclaesson
Copy link

svenclaesson commented Nov 26, 2024

We are using SQLite (in tests) and experience this error. It's still dependent on Pomelo MySql?

@borisdj
Copy link
Owner

borisdj commented Nov 26, 2024

Not sure, will check it out in a few days.

@Pete-PlaytimeSolutions
Copy link

Just an FYI on what I have found, when using against the "Microsoft.EntityFrameworkCore.SqlServer" Provider.

I think its failing in IQueryableExtensions.ToParametrizedSql method, due to one or more of the "enumerator" private fields no longer existing in net 9.0..

When running under net8.0, the private field "_relationalCommandCache" always seems to be populated,
whereas under net 9.0 if no longer exists.

i.e

string privateField = "_relationalCommandCache";
RelationalCommandCache relationalCommandCache = (RelationalCommandCache)enumerator.Private(privateField);

NOTE: When relationalCommandCache is null, the following fallback code does not work for either versions,
due to the private field "_selectExpression" not being available in either net8.0 or net 9.0.

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

No branches or pull requests

4 participants