Beispiel #1
0
        EntityClass Create2(IDataTable table)
        {
            var entity = new EntityClass();
            entity.Assembly = this;
            entity.ClassName = table.Alias;
            entity.Table = table;
            //entity.FieldNames = fieldNames;
            entity.Create();
            entity.AddProperties();
            entity.AddIndexs();
            //entity.AddNames();

            Classes.Add(entity);
            return entity;
        }
Beispiel #2
0
        /// <summary>在该程序集中创建一个实体类</summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public EntityClass Create(IDataTable table)
        {
            // 复制一份,以免修改原来的结构
            IDataTable tb = table.Clone() as IDataTable;
            //String className = tb.Name.Replace("$", null);

            //// 计算名称,防止属性名和类型名重名
            //StringCollection list = new StringCollection();
            //list.Add("Item");
            //list.Add("System");
            //list.Add(className);

            //// 保存属性名,可能跟字段名不一致
            //Dictionary<String, String> fieldNames = new Dictionary<String, String>(StringComparer.OrdinalIgnoreCase);
            //foreach (IDataColumn item in tb.Columns)
            //{
            //    String name = item.Name;
            //    for (int i = 2; list.Contains(name); i++)
            //    {
            //        name = item.Name + i;
            //    }
            //    //item.Name = name;
            //    fieldNames.Add(item.Name, name);
            //}

            EntityClass entity = new EntityClass();
            entity.Assembly = this;
            entity.ClassName = tb.Alias;
            entity.Table = tb;
            //entity.FieldNames = fieldNames;
            entity.Create();
            entity.AddProperties();
            entity.AddIndexs();
            //entity.AddNames();

            Classes.Add(entity);
            return entity;
        }