public static TableMetadata Deserialize(BinaryReader input) { var dtList = new List <DerivativeTable>(); var fkList = new List <ForeignKey>(); var schemaColList = new List <ColumnDefinition>(); var t = new TableMetadata(input.ReadString()) { IsStatic = input.ReadBoolean(), SelectCommand = input.ReadString(), InsertCommand = input.ReadString() }; var nbRows = input.ReadInt32(); for (var i = 0; i < nbRows; i++) { dtList.Add(new DerivativeTable { ServerId = input.ReadInt16(), Database = input.ReadString(), Schema = input.ReadString(), Table = input.ReadString(), Access = (DerivativeTableAccess)input.ReadInt32(), Cascade = input.ReadBoolean() }); } nbRows = input.ReadInt32(); for (var i = 0; i < nbRows; i++) { var fkColList = new List <ForeignKeyColumn>(); var fk = new ForeignKey { ServerIdTo = input.ReadInt16(), DatabaseTo = input.ReadString(), SchemaTo = input.ReadString(), TableTo = input.ReadString() }; var nbRows2 = input.ReadInt32(); for (var j = 0; j < nbRows2; j++) { fkColList.Add(new ForeignKeyColumn { NameFrom = input.ReadString(), NameTo = input.ReadString() }); } fk.Columns = fkColList; fkList.Add(fk); } nbRows = input.ReadInt32(); for (var i = 0; i < nbRows; i++) { schemaColList.Add(new ColumnDefinition { Name = input.ReadString(), DbType = (DbType)input.ReadInt32(), IsPrimary = input.ReadBoolean(), IsForeignKey = input.ReadBoolean(), IsAutoIncrement = input.ReadBoolean(), BuilderName = input.ReadString(), SqlType = SqlType.Deserialize(input) }); } t.DerivativeTables = dtList; t.ForeignKeys = fkList; t.ColumnsDefinition = schemaColList; return(t); }