using iWareCommon.Common.Entity; using iWareCommon.Utils; using iWareDataCore.ORM; using System.Collections.Generic; using System.Linq; namespace iWareDataCore.BASE.Entity { public class MaterialTypeEntity : ICommonEntity { /// /// 1主键id /// public int Id { get; set; } /// /// 2物料类型名称 /// public string Name { get; set; } /// /// 3备注 /// public string Remark { get; set; } /// /// 4类型 /// public int Type { get; set; } /// /// 无参构造 /// public MaterialTypeEntity() { } /// /// 有参构造 /// /// orm映射的类 public MaterialTypeEntity(BASEMaterialType type) { EntityPropHelper.CopyProp(type, this, GetColumnMap()); } /// /// 转换视图的方法 /// /// public MaterialTypeEntity(MaterialTypeViewEntity type) { var keys = GetColumnMap().Keys.ToList(); var columnMap = new Dictionary(); keys.ForEach(x => columnMap.Add(x, x)); EntityPropHelper.CopyProp(type, this, columnMap); } /// /// 将对象转换成ORM中的类型 /// /// Orm中的BASEMaterialType类型 public BASEMaterialType ToOrm() { BASEMaterialType type = new BASEMaterialType(); EntityPropHelper.CopyProp(this, type, GetColumnMap()); return type; } /// /// 获取自定义角色类中的字段名为键,orm中对象的字段名为值的字段 /// /// public static Dictionary GetColumnMap() { return new Dictionary() { {"Id", "id"}, {"Name", "name"}, {"Remark", "remark"}, {"Type", "type"} }; } /// /// 根据MaterialTypeEntity的字段转BASEMaterialType的字段 /// /// MaterialTypeEntity的字段 /// BASEMaterialType public static string GetColumnName(string name) { var columnMap = GetColumnMap(); return columnMap.ContainsKey(name) ? columnMap[name] : name; } /// /// 获取MaterialTypeEntity对应的表名 /// /// 表名 public static string GetTableName() { return "[dbo].[BASEMaterialType]"; } } }