-
Notifications
You must be signed in to change notification settings - Fork 57
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
DiagnosticListener.AllListeners #588
Comments
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 |
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 |
Hello @amccorma , Unfortunately, no, EF Plus (for EF Core) still doesn't support interceptors. Best Regards, Jon |
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());
}
}
|
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 |
Description
We use multiple database with different schemas with EF Core 7.0
We have a global command listener that changes the schema name before it executes.
Program.cs
DiagnosticListener.AllListeners.Subscribe(new GlobalListener());
public class GlobalListener : IObserver
The EntityFramework-Extensions never executes this block of code and I get exceptions saying the tables do not exists. It is the only way we can do it with our database design.
Is there a workaround for this issue? I need the schema/table names changed before the statements execute.
Exception
table does not exist
The text was updated successfully, but these errors were encountered: