overtly / core-data Goto Github PK
View Code? Open in Web Editor NEW基于Dapper封装的Linq表达式数据库访问驱动,内置自定义分库,分表的实现
基于Dapper封装的Linq表达式数据库访问驱动,内置自定义分库,分表的实现
有没有事务的test
如果使用时间做为表名规则,写数据应该没有问题,但是跨天的临界点后就可能出现数据查询不到的问题。比如微信支付,支付结果回写的时候可能跨过了时间点。
public override Func<string> TableNameFunc => () =>
{
var tableName = $"{GetMainTableName()}_{DateTime.Now.ToString("yyyyMMdd")}";
return tableName;
};
CheckTableIfMissingCreate此方法在判定TableNameFunc方法不存在的情况下,建议自动获取一下表名,这样普通继承的仓储类就没必要必须实现CheckTableIfMissingCreate和CreateScriptFunc;例如修改为下面这样:
public static bool CheckTableIfMissingCreate(this IBaseRepository repository, bool isMaster)
where T : class, new()
{
var tableName = repository.TableNameFunc?.Invoke();
if (string.IsNullOrEmpty(tableName))
tableName = repository.GetMainTableName();
var createScript = repository.CreateScriptFunc?.Invoke(tableName);
if (string.IsNullOrEmpty(createScript))
return true;
var tableKey = $"{repository.DbStoreKey}_{tableName}_{isMaster}";
var existTable = ExistInformation.GetOrAdd(tableKey, k => repository.IsExistTable(tableName, isMaster));
if (!existTable)
{
ExistInformation.TryRemove(tableKey, out existTable);
if (!isMaster)
return false;
try
{
using (var connection = repository.OpenConnection(true, true))
{
connection.ExecuteAsync(createScript).GetAwaiter().GetResult();
}
}
catch (Exception ex)
{
throw ex;
}
}
return true;
}
大佬能否给个.NetFrameWork与.NetCore项目下使用的小项目呀,单元测试不是很清晰,求帮助!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.