Ai
65 Star 543 Fork 117

GVP薛家明/sharding-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ShardingModelCacheKeyFactory.cs 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
薛家明 提交于 2022-07-20 13:47 +08:00 . 移除不必要的debug信息
using System;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using ShardingCore.Core.DbContextCreator;
using ShardingCore.Sharding.Abstractions;
namespace ShardingCore.EFCores
{
/*
* @Author: xjm
* @Description:
* @Date: Wednesday, 16 December 2020 16:13:05
* @Email: 326308290@qq.com
*/
public class ShardingModelCacheKeyFactory : IModelCacheKeyFactory
{
public object Create(DbContext context)
{
return Create(context, false);
}
public object Create(DbContext context, bool designTime)
{
if (context is IShardingTableDbContext shardingTableDbContext && shardingTableDbContext.RouteTail != null && !string.IsNullOrWhiteSpace(shardingTableDbContext.RouteTail.GetRouteTailIdentity()))
{
return $"{context.GetType()}_{shardingTableDbContext.RouteTail.GetRouteTailIdentity()}_{designTime}";
}
else
{
return (context.GetType(),designTime);
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/xuejm/sharding-core.git
git@gitee.com:xuejm/sharding-core.git
xuejm
sharding-core
sharding-core
main

搜索帮助