示例#1
0
        private void SendColumnDefinition(QuerySetup querySetup)
        {
            List <byte> columnDefinition = new List <byte>();

            columnDefinition.AddRange(new byte[] { 0x07, 0x00, 0x00 });

            foreach (var column in querySetup.Schema)
            {
                columnDefinition.Add((byte)column.type);
                columnDefinition.AddRange(BitConverter.GetBytes((short)column.length));
                columnDefinition.AddRange(BitConverter.GetBytes((short)column.name.Length));
                columnDefinition.AddRange(Encoding.UTF8.GetBytes(column.name));
            }

            var length = BitConverter.GetBytes((short)columnDefinition.Count - 3);
            var bytes  = columnDefinition.ToArray();

            bytes[1] = length[0];
            bytes[2] = length[1];

            stream.Write(bytes, 0, bytes.Length);
        }