Comments (5)
i got it it working with adding an interceptor. I test it and it works. Ef Core 7.0
In EfContext class:
DbInterception.Add(new Org.Infrastructure.Interceptor.MyCommandInterceptor());
public class MyCommandInterceptor : Z.EntityFramework.Extensions.IDbInterceptor
{
public void OnCompleted()
{
}
public void OnError(Exception error)
{
}
public void OnNext(DiagnosticListener value)
{
value.Subscribe(new My2());
}
}
public class My2 : System.IObserver<KeyValuePair<string, object?>>
{
public void OnCompleted()
{
}
public void OnError(Exception error)
{
}
public void OnNext(KeyValuePair<string, object?> value)
{
if (value.Key == "Microsoft.Data.SqlClient.WriteCommandBefore" ||
value.Key == "Microsoft.EntityFrameworkCore.Database.Command.CommandInitialized")
{
var obj = ToDynamic(value.Value);
var command = obj.Command as Microsoft.Data.SqlClient.SqlCommand;
if (command != null)
{
command.CommandText = command.CommandText
.Replace("[X.X1]", "[X.[X1]")
.Replace("[X3.X4].", "[X3].[X4].");
}
}
}
from entityframework-extensions.
Hello @amccorma ,
You are right; our library doesn't use a listener or interceptor.
You should be able to change the table name within our library with the PostConfiguration event.
Here is an example:
// globally
Z.EntityFramework.Extensions.EntityFrameworkManager.BulkOperationBuilder = builder => builder.PostConfiguration = configuration =>
{
configuration.DestinationTableName = configuration.DestinationTableName
.Replace("[X.Shared].", "[X].[Shared].")
.Replace("[X1.Common].", "[X1].[Common].")
.Replace("[X2.Primary]","[X2].[Primary]")
};
// or by operation (which override the globally for the specific option)
context.BulkSaveChanges(options => options.PostConfiguration = configuration =>
{
configuration.DestinationTableName = configuration.DestinationTableName
.Replace("[X.Shared].", "[X].[Shared].")
.Replace("[X1.Common].", "[X1].[Common].")
.Replace("[X2.Primary]","[X2].[Primary]")
});
It might be slightly different depending of what exactly you want to do, but I believe you will be able to find out how to make it work correctly with this information.
Let me know if that solves your current problem or if you need more help.
Best Regards,
Jon
from entityframework-extensions.
That worked ok for the Framework.Extensions.
Do you have a similar method for the Z.EntityFramework.Plus framework = the future, cache functions. I checked and can not find anything. the code above does nothing for the Plus framework. Thanks
from entityframework-extensions.
Hello @amccorma ,
Unfortunately, no, EF Plus (for EF Core) still doesn't support interceptors.
Best Regards,
Jon
from entityframework-extensions.
Indeed, I was wrong,
It makes sense that it works with the Query Cache features in EF Core.
I'm surprised that you were able to make it work for Query Future. Thank you for sharing your solution. I tried it, and it worked, so we will surely look more deeply into it.
Best Regards,
Jon
from entityframework-extensions.
Related Issues (20)
- `PublicExtensions` static dictionaries are filling up HOT 4
- SQLite Invalid cast from 'System.String' to 'System.Guid' HOT 4
- IDbCommandInterceptor does not fire when using BulkInsert or BulkDelete HOT 2
- WhereBulkContains does not work when table inherit from another table HOT 1
- Feat: Conditional insert HOT 16
- EFcore 8 UpdateFromQuery generates invalid sql HOT 5
- Microsoft.Data.SqlClient is on a vulnerable version - security update HOT 1
- BulkInsert ignoring session context value set before insert HOT 10
- BulkInsert - ERROR_34 HOT 17
- Z.EntityFramework.Plus.EFCore - Official behavior on DataAnnotations ? HOT 1
- Feat: IncludeInner extension method to force Parent/Children inner joins HOT 6
- BatchSaveChanges should support operation.AllowConcurrency = false HOT 6
- BulkInsertAsync throw errors not supporting ARRAY HOT 5
- UpdateFromQueryAsync with DbCommandInterceptor HOT 2
- Open connections asynchronously when using AAD authentication HOT 8
- Support Microsoft.Data.SqlClient for BatchSaveChanges HOT 4
- WhereBulkContains returns duplicate rows from the DB HOT 1
- Error in BulkSynchronizeAsync HOT 1
- BulkMerge not inserting records in Temporal table HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entityframework-extensions.