希望可以增加多一种实体映射模式,字段对象只映射其中一个字段到数据库,名称还是对象名 #889
kensmaster
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
比如:public CodeTable Sex{get;set;}
下面这个对象是所有码表字段通用对象
public class CodeTable {
public string Code{get;set;} 该字段用于保存数据库,如:1,2,3
public string Name{get;set;} 该字段用于其他表解析Code返回页面显示
}
请看EF实现:
//UserInfo
var myUserInfo = builder.Entity().ToTable("UserInfo", "public");
myUserInfo.Property(e => e.Sex.Code).HasColumnName("Sex");
myUserInfo.Property(e => e.FactoryType.Code).HasColumnName("FactoryType");
myUserInfo.Property(e => e.Dept.Code).HasColumnName("Dept");
myUserInfo.Property(e => e.LineType.Code).HasColumnName("LineType");
Beta Was this translation helpful? Give feedback.
All reactions