private TableMapping CreateTableMapping(TableAttribute tableattribute, Type type) { TableMapping table = new TableMapping(); table.Name = tableattribute.Name; table.ObjectType = type; if (string.IsNullOrEmpty(table.Name)) { table.Name = table.ObjectType.Name; } List <PropertyInfo> props = new List <PropertyInfo>(); GetProperties(table, type, props); foreach (PropertyInfo prop in props) { ColumnAttribute columnattribute = Attribute.GetCustomAttribute(prop, typeof(ColumnAttribute)) as ColumnAttribute; if (columnattribute == null) { table.OtherPropertys.Add(prop); } else { ColumnMapping column = new ColumnMapping(); column.Name = columnattribute.Name; column.PropertyInfo = prop; column.IsViewColumn = columnattribute.IsViewColumn; if (string.IsNullOrEmpty(column.Name)) { column.Name = prop.Name; } column.IsAutoIncrement = columnattribute.IsAutoIncrement; column.IsPK = columnattribute.IsPK; column.IsUseSeedFactory = columnattribute.IsUseSeedFactory; //-------------------------------------------------------------------------------------------------------------------- Attribute[] attrs = Attribute.GetCustomAttributes(prop); foreach (Attribute attr in attrs) { if (attr is DataInterceptAttribute) { if (column.DataIntercept == null) { DataInterceptAttribute dataintercept = attr as DataInterceptAttribute; dataintercept.ColumnMapping = column; column.DataIntercept = dataintercept; } else { throw new ObjectMappingException("Property have more DataInterceptAttribute define"); } } } //-------------------------------------------------------------------------------------------------------------------- table.AddColumnMapping(column); } } if (table.ColumnPK == null) { throw new ObjectMappingException("not find primary key"); } return(table); }