forked from anjoy8/Blog.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplitDemo.cs
More file actions
27 lines (23 loc) · 979 Bytes
/
SplitDemo.cs
File metadata and controls
27 lines (23 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Blog.Core.Model.Models
{
[SplitTable(SplitType.Day)]//按天分表 (自带分表支持 年、季、月、周、日)
[SugarTable("SplitDemo_{year}{month}{day}")]//3个变量必须要有,这么设计为了兼容开始按年,后面改成按月、按日
public class SplitDemo
{
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
public string Name { get; set; }
[SugarColumn(IsNullable = true)]//设置为可空字段 (更多用法看文档 迁移)
public DateTime UpdateTime { get; set; }
[SplitField] //分表字段 在插入的时候会根据这个字段插入哪个表,在更新删除的时候用这个字段找出相关表
public DateTime CreateTime { get; set; }
}
}