You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/DB/SystemEntityTypeBuilder.cs

83 lines
2.1 KiB
C#

3 months ago
using Chloe.Annotations;
using Chloe.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DB
{
public abstract class SystemEntityTypeBuilder<T> : EntityTypeBuilder<T> where T : BaseChimsDb
{
protected SystemEntityTypeBuilder(string tableName)
{
this.MapTo(tableName);
this.Property(a => a.ID).IsAutoIncrement(false).IsPrimaryKey();
this.UpdateIgnore(x => x.CreateUserId);
2 months ago
this.Property(x => x.CreateUserId).HasSize(19);
this.Property(x => x.LastModifyUserId).HasSize(19);
this.Property(x => x.CreateUserName).HasSize(10);
this.Property(x => x.LastModifyUserName).HasSize(10);
this.Property(x => x.IsEnable).HasSize(1);
this.Property(x => x.IsDelete).HasSize(1);
3 months ago
this.UpdateIgnore(x => x.CreateDate);
this.UpdateIgnore(x => x.CreateUserName);
HasQueryFilter(x => x.IsDelete == 0 && x.IsEnable == 1);
}
}
public class BaseChimsDb
{
[Column(IsPrimaryKey = true)]
[NonAutoIncrement]
public long ID { get; set; }
/// <summary>
/// </summary>
2 months ago
public short IsEnable { get; set; } = 1;
3 months ago
/// <summary>
/// </summary>
2 months ago
public short IsDelete { get; set; } = 0;
3 months ago
/// <summary>
/// </summary>
[UpdateIgnore]
public DateTime CreateDate { get; set; } = DateTime.Now;
/// <summary>
/// </summary>
[UpdateIgnore]
2 months ago
3 months ago
public string CreateUserId { get; set; } = "";
/// <summary>
/// </summary>
[UpdateIgnore]
2 months ago
3 months ago
public string CreateUserName { get; set; } = "";
/// <summary>
/// </summary>
public DateTime LastModifyDate { get; set; } = DateTime.Now;
2 months ago
3 months ago
/// <summary>
/// </summary>
public string LastModifyUserId { get; set; } = "";
2 months ago
3 months ago
/// <summary>
/// </summary>
public string LastModifyUserName { get; set; } = "";
2 months ago
3 months ago
}
}