Commit e2141433 by dingsongjie

删除 不必要的 类

parent 7819603e
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System;
using System.Collections.Generic;
using System.Text;
namespace Pole.Orleans.Provider.EntityframeworkCore
{
public class DefaultGrainStateEntryConfigurator<TContext, TGrain, TEntity>
: IGrainStateEntryConfigurator<TContext, TGrain, TEntity>
where TContext : DbContext
where TEntity : class
{
public void ConfigureSaveEntry(ConfigureSaveEntryContext<TContext, TEntity> context)
{
if (context.IsPersisted)
{
// todo update necessary table
//EntityEntry<TEntity> entry = context.DbContext.Set<TEntity>().Update(context.Entity);
}
else
{
EntityEntry<TEntity> entry = context.DbContext.Set<TEntity>().Add(context.Entity);
}
//entry.State = context.IsPersisted
// ? EntityState.Modified
// : EntityState.Added;
}
}
}
......@@ -55,8 +55,6 @@ namespace Pole.Orleans.Provider.EntityframeworkCore
{
services.TryAddSingleton(typeof(IEntityTypeResolver), typeof(EntityTypeResolver));
services.TryAddSingleton(typeof(IGrainStorageConvention), typeof(GrainStorageConvention));
services.TryAddSingleton(typeof(IGrainStateEntryConfigurator<,,>),
typeof(DefaultGrainStateEntryConfigurator<,,>));
services.AddSingleton(typeof(EntityFrameworkGrainStorage<TContext>));
services.TryAddSingleton<IGrainStorage>(sp =>
......
......@@ -28,7 +28,6 @@ namespace Pole.Orleans.Provider.EntityframeworkCore
private readonly IServiceScopeFactory _scopeFactory;
private readonly ILogger<GrainStorage<TContext, TGrain, TGrainState, TEntity>> _logger;
private readonly IServiceProvider _serviceProvider;
private readonly IGrainStateEntryConfigurator<TContext, TGrain, TEntity> _entryConfigurator;
public GrainStorage(string grainType, IServiceProvider serviceProvider)
{
......@@ -37,9 +36,6 @@ namespace Pole.Orleans.Provider.EntityframeworkCore
_serviceProvider = serviceProvider
?? throw new ArgumentNullException(nameof(serviceProvider));
_entryConfigurator = (IGrainStateEntryConfigurator<TContext, TGrain, TEntity>)serviceProvider.GetRequiredService(
typeof(IGrainStateEntryConfigurator<TContext, TGrain, TEntity>));
var loggerFactory = _serviceProvider.GetService<ILoggerFactory>();
_logger = loggerFactory?.CreateLogger<GrainStorage<TContext, TGrain, TGrainState, TEntity>>()
?? NullLogger<GrainStorage<TContext, TGrain, TGrainState, TEntity>>.Instance;
......
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
namespace Pole.Orleans.Provider.EntityframeworkCore
{
public interface IGrainStateEntryConfigurator<TContext, TGrain, TEntity>
where TContext : DbContext
where TEntity : class
{
void ConfigureSaveEntry(ConfigureSaveEntryContext<TContext, TEntity> context);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment