sharding/samples/Sample.MySql/MySaveChangeInterceptor.cs

17 lines
657 B
C#
Raw Normal View History

2023-11-24 15:56:32 +08:00
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
namespace Sample.MySql
{
public class MySaveChangeInterceptor:SaveChangesInterceptor
{
public override ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEventData eventData, InterceptionResult<int> result,
CancellationToken cancellationToken = new CancellationToken())
{
var myCurrentUser = eventData.Context.GetService<MyCurrentUser>();
Console.WriteLine("1"+myCurrentUser!=null);
return base.SavingChangesAsync(eventData, result, cancellationToken);
}
}
}