public void CloneDataTable(DataTable table) { this.TableName = table.TableName; if (table.ExtendedProperties.ContainsKey(TableProperty.FieldAddrDic)) { this.ExtendedProperties.Add(TableProperty.FieldAddrDic, table.ExtendedProperties[TableProperty.FieldAddrDic]); } if (table.ExtendedProperties.ContainsKey(TableProperty.IsVirtual)) { this.ExtendedProperties.Add(TableProperty.IsVirtual, table.ExtendedProperties[TableProperty.IsVirtual]); } foreach (DataColumn column in table.Columns) { LibSqlModelColumn newColumn = new LibSqlModelColumn(); newColumn.CloneDataColumn(column); this.Columns.Add(newColumn); } DataColumn[] pks = new DataColumn[table.PrimaryKey.Length]; for (int i = 0; i < table.PrimaryKey.Length; i++) { pks[i] = this.Columns[table.PrimaryKey[i].ColumnName]; } this.PrimaryKey = pks; }