mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Add demo
This commit is contained in:
parent
28f9b36992
commit
b1a758fe61
23
Src/Asp.NetCore2/CacheTest/Order.cs
Normal file
23
Src/Asp.NetCore2/CacheTest/Order.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CacheTest
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
public class Order
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
public decimal Price { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
[SugarColumn(IsNullable =true)]
|
||||||
|
public int CustomId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace CacheTest
|
namespace CacheTest
|
||||||
{
|
{
|
||||||
@ -17,6 +18,25 @@ namespace CacheTest
|
|||||||
var testr=cache.GetOrCreate<string>("a33",()=> { return "aaa"; },10);
|
var testr=cache.GetOrCreate<string>("a33",()=> { return "aaa"; },10);
|
||||||
cache.Remove<string>("aaaaaaaa");
|
cache.Remove<string>("aaaaaaaa");
|
||||||
cache.Remove<string>("a");
|
cache.Remove<string>("a");
|
||||||
|
ICacheService myCache = cache;
|
||||||
|
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST",
|
||||||
|
DbType = DbType.SqlServer,
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
MoreSettings=new ConnMoreSettings() {
|
||||||
|
IsAutoRemoveDataCache = true,
|
||||||
|
},
|
||||||
|
ConfigureExternalServices = new ConfigureExternalServices()
|
||||||
|
{
|
||||||
|
DataInfoCacheService = myCache //配置我们创建的缓存类,具体用法看标题5
|
||||||
|
}
|
||||||
|
});
|
||||||
|
db.Fastest<Order>().BulkCopy(new System.Collections.Generic.List<Order>()
|
||||||
|
{
|
||||||
|
new Order(){ CreateTime=DateTime.Now, CustomId=1, Name="a" }
|
||||||
|
});
|
||||||
Console.WriteLine("Hello World!");
|
Console.WriteLine("Hello World!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user