学海无涯

导航

统计

C# 智能枚举

1
2
3
4
5
6
7
public class PriorityStatus : SmartEnum<PriorityStatus>
{
  public static readonly PriorityStatus Backlog = new(nameof(Backlog), 0);
  public static readonly PriorityStatus Critical = new(nameof(Critical), 1);
 
  protected PriorityStatus(string name, int value) : base(name, value) { }
}

客户端使用:

1
public ProjectStatus Status => _items.All(i => i.IsDone) ? ProjectStatus.Complete : ProjectStatus.InProgress;

 基础设施,数据库的实体配置类:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using XFMES.Core.ApsAggregate;
using XFMES.Core.ProjectAggregate;
 
namespace XFMES.Infrastructure.Data.Config.Aps;
public class ShpFcNomarkDetailConfig : IEntityTypeConfiguration<ShpFcNomarkDetail>
{
  public void Configure(EntityTypeBuilder<ShpFcNomarkDetail> builder)
  {
    builder.Property(p => p.DepartmentCategories)
      .HasConversion(
          p => p.Value,
          p => DepartmentCategories.FromValue(p));
  }
}

  

 

 

posted on   宁静致远.  阅读(73)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
· 零经验选手,Compose 一天开发一款小游戏!
点击右上角即可分享
微信分享提示