mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-12-26 01:45:49 +08:00
拆分 FreeSql 按需引用
This commit is contained in:
@@ -230,8 +230,8 @@ namespace FreeSql.Tests.MySql {
|
||||
|
||||
});
|
||||
|
||||
var t100 = g.mysql.Select<TestInfo>().Where("").Where(a => a.Id > 0).Skip(100).Limit(200).Caching(50).ToList();
|
||||
var t101 = g.mysql.Select<TestInfo>().As("b").Where("").Where(a => a.Id > 0).Skip(100).Limit(200).Caching(50).ToList();
|
||||
var t100 = g.mysql.Select<TestInfo>().Where("").Where(a => a.Id > 0).Skip(100).Limit(200).ToList();
|
||||
var t101 = g.mysql.Select<TestInfo>().As("b").Where("").Where(a => a.Id > 0).Skip(100).Limit(200).ToList();
|
||||
|
||||
|
||||
var t1111 = g.mysql.Select<TestInfo>().ToList(a => new { a.Id, a.Title, a.Type });
|
||||
@@ -304,16 +304,6 @@ namespace FreeSql.Tests.MySql {
|
||||
Assert.StartsWith(" SELECT", select.Master().Where(a => 1 == 1).ToSql());
|
||||
}
|
||||
[Fact]
|
||||
public void Caching() {
|
||||
var result1 = select.Where(a => 1 == 1).Caching(20, "testcaching").ToList();
|
||||
var testcaching1 = g.mysql.Cache.Get("testcaching");
|
||||
Assert.NotNull(testcaching1);
|
||||
var result2 = select.Where(a => 1 == 1).Caching(20, "testcaching").ToList();
|
||||
var testcaching2 = g.mysql.Cache.Get("testcaching");
|
||||
Assert.NotNull(testcaching2);
|
||||
Assert.Equal(result1.Count, result1.Count);
|
||||
}
|
||||
[Fact]
|
||||
public void From() {
|
||||
var query2 = select.From<TestTypeInfo>((s, b) => s
|
||||
.LeftJoin(a => a.TypeGuid == b.Guid)
|
||||
|
||||
@@ -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