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

75 lines
1.8 KiB
C#

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);
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>
public int IsEnable { get; set; } = 1;
/// <summary>
/// </summary>
public int IsDelete { get; set; } = 0;
/// <summary>
/// </summary>
[UpdateIgnore]
public DateTime CreateDate { get; set; } = DateTime.Now;
/// <summary>
/// </summary>
[UpdateIgnore]
public string CreateUserId { get; set; } = "";
/// <summary>
/// </summary>
[UpdateIgnore]
public string CreateUserName { get; set; } = "";
/// <summary>
/// </summary>
public DateTime LastModifyDate { get; set; } = DateTime.Now;
/// <summary>
/// </summary>
public string LastModifyUserId { get; set; } = "";
/// <summary>
/// </summary>
public string LastModifyUserName { get; set; } = "";
public int SortCode { get; set; } = 0;
}
}