using iWareCommon.Common.Entity; using iWareCommon.Utils; using iWareExcel.ORM; using System; using System.Collections.Generic; namespace iWareExcel.EXCEL.Entity { public class WorkCellEntity : ICommonEntity { /// /// 主键 /// public int Id { get; set; } /// /// Excel展示名 /// public string DisplayName { get; set; } /// /// 属性名 /// public string PropName { get; set; } /// /// 工作页Id /// public int WorkSheetId { get; set; } /// /// 工作页名称 /// public string WorkSheetName { get; set; } /// /// 工作簿Id /// public int WorkBookId { get; set; } /// /// 工作簿名称 /// public string WorkBookName { get; set; } /// /// 数据类型 /// public int DataType { get; set; } /// /// 是否枚举 /// public int IsEnum { get; set; } /// /// 枚举类名 /// public string EnumClass { get; set; } /// /// 排序 /// public int CellIndex { get; set; } /// /// 构造函数 /// public WorkCellEntity(){} /// /// 构造函数 /// /// 工作单元 public WorkCellEntity(EXCELWorkCell workCell) { EntityPropHelper.CopyProp(workCell, this, GetColumnMap()); } /// /// 将实体类转成ORM类 /// /// public EXCELWorkCell ToOrm() { var workCell = new EXCELWorkCell(); EntityPropHelper.CopyProp(this, workCell, GetColumnMap()); return workCell; } /// /// 获取自定义工位类中的字段名为键,orm中对象的字段名为值的字段 /// /// public static Dictionary GetColumnMap() { return new Dictionary() { {"Id", "id"}, {"DisplayName", "displayname"}, {"PropName","propname"}, {"WorkSheetId","worksheetid"}, {"WorkSheetName","worksheetname"}, {"WorkBookId","workbookid"}, {"WorkBookName","workbookname"}, {"DataType","datatype"}, {"IsEnum","isenum"}, {"EnumClass","enumclass"}, {"CellIndex", "cellindex"} }; } /// /// 根据Entity的字段转ORM的字段 /// /// /// public static String GetColumnName(String name) { var columnMap = GetColumnMap(); return columnMap.ContainsKey(name) ? columnMap[name] : name; } public static string GetTableName() { return "[dbo].[EXCELWorkCell]"; } } }