using iWareCommon.Common.Entity; using iWareCommon.Utils; using iWareExcel.ORM; using System.Collections.Generic; namespace iWareExcel.EXCEL.Entity { public class WorkSheetEntity : ICommonEntity { /// /// 主键 /// public int Id { get; set; } /// /// 工作页名称 /// public string Name { get; set; } /// /// 工作簿Id /// public int WorkBookId { get; set; } /// /// 工作簿名称 /// public string WorkBookName { get; set; } /// /// 工作页对应的实体全类名 /// public string ClassName { get; set; } /// /// 排序 /// public int SheetIndex { get; set; } /// /// 工作单元列表 /// public List WorkCells { get; set; } /// /// 表头写入开始行 从1开始 /// public int HeadStartLine { get; set; } /// /// 数据写入开始行 从1开始 /// public int DataStartLine { get; set; } /// /// 无参构造 /// public WorkSheetEntity() { WorkCells = new List(); } /// /// 有参构造 /// /// orm印射的类 public WorkSheetEntity(EXCELWorkSheet workSheet) { EntityPropHelper.CopyProp(workSheet, this, GetColumnMap()); WorkCells = new List(); } /// /// 获取自定义角色类中的字段名为键,orm中对象的字段名为值的字段 /// /// public static Dictionary GetColumnMap() { return new Dictionary() { {"Id", "id"}, {"Name", "name"}, {"WorkBookId", "workbookid"}, {"WorkBookName", "workbookname"}, {"ClassName", "classname"}, {"HeadStartLine","headstartline"}, {"DataStartLine","datastartline"}, {"SheetIndex","sheetindex"} }; } /// /// 将对象转换成ORM中的类型 /// /// Orm中的BASEShift类型 public EXCELWorkSheet ToOrm() { EXCELWorkSheet workSheet = new EXCELWorkSheet(); EntityPropHelper.CopyProp(this, workSheet, GetColumnMap()); return workSheet; } /// /// 根据ShiftEntity的字段转BASEShift的字段 /// /// ShiftEntity的字段 /// BASEShift public static string GetColumnName(string name) { var columnMap = GetColumnMap(); return columnMap.ContainsKey(name) ? columnMap[name] : name; } /// /// 获取ShiftEntity对应的表名 /// /// 表名 public static string GetTableName() { return "[dbo].[EXCELWorkSheet]"; } } }