mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-12-26 01:45:49 +08:00
拆分 FreeSql 按需引用
This commit is contained in:
@@ -385,27 +385,11 @@ namespace FreeSql.Tests.MySql {
|
||||
internal static IFreeSql mysql => null;
|
||||
public static FreeSql.ISelect<Tb_alltype> Select => mysql.Select<Tb_alltype>();
|
||||
|
||||
public static int ItemCacheTimeout = 180;
|
||||
public static Tb_alltype GetItem(int Id) => Select.Where(a => a.Id == Id).Caching(ItemCacheTimeout, string.Concat("test:tb_alltype:", Id)).ToOne();
|
||||
|
||||
public static long Delete(int Id) {
|
||||
var affrows = mysql.Delete<Tb_alltype>().Where(a => a.Id == Id).ExecuteAffrows();
|
||||
if (ItemCacheTimeout > 0) RemoveCache(new Tb_alltype { Id = Id });
|
||||
return affrows;
|
||||
}
|
||||
|
||||
internal static void RemoveCache(Tb_alltype item) => RemoveCache(item == null ? null : new[] { item });
|
||||
internal static void RemoveCache(IEnumerable<Tb_alltype> items) {
|
||||
if (ItemCacheTimeout <= 0 || items == null || items.Any() == false) return;
|
||||
var keys = new string[items.Count() * 1];
|
||||
var keysIdx = 0;
|
||||
foreach (var item in items) {
|
||||
keys[keysIdx++] = string.Concat("test:tb_alltype:", item.Id);
|
||||
}
|
||||
if (mysql.Ado.TransactionCurrentThread != null) mysql.Ado.TransactionPreRemoveCache(keys);
|
||||
else mysql.Cache.Remove(keys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Update<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӱ<EFBFBD><D3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ 0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Insert
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user