Open
Description
现在后台系统都需会有字典管理功能, 其实就一张KV大表, 放了很多值用type做区分,
有没优雅的视实现的方式, 可以映射 不同的类型到这个大表?
Feature 特性
public class Dictionary
{//通用配置表 , 实际建表
public string Id{get;set;}
public string A{get;set;}
public string B{get;set;}
public string C{get;set;}
public string D{get;set;}
public string Type{get;set;}
}
简要描述原因
[Map(typeof(Dictionary), where:"type=ConfigA")]
public class ConfigA
{// 类映射到Dictionary , 不建表, 有点像导航属性
public string Id{get;set;}
[Map("A")]
public string A1{get;set;}
[Map("B")]
public string B1{get;set;}
[Map("C")]
public string C1{get;set;}
}
类似这样, 就把 ConfigA 映射到 Dictionary , 通过type=ConfigA进行过滤, 字段也进行了映射, 可以进行crud, 最终操作还是Dictionary的操作
使用场景
这样就非常方便优雅
// c# code
Metadata
Metadata
Assignees
Labels
No labels