Ejemplo n.º 1
0
        public override void Execute()
        {
            // if we are not prepared, then call down to our base
            if (!IsPrepared)
            {
                base.Execute();
                return;
            }

            //TODO: support long data here
            // create our null bitmap

            // we check this because Mono doesn't ignore the case where nullMapBytes
            // is zero length.
            //            if (nullMapBytes.Length > 0)
            //          {
            //            byte[] bits = packet.Buffer;
            //          nullMap.CopyTo(bits,
            //        nullMap.CopyTo(nullMapBytes, 0);

            // start constructing our packet
            //            if (Parameters.Count > 0)
            //              nullMap.CopyTo(packet.Buffer, nullMapPosition);
            //if (parameters != null && parameters.Count > 0)
            //else
            //	packet.WriteByte( 0 );
            //TODO:  only send rebound if parms change

            // now write out all non-null values
            packet.Position = dataPosition;
            for (int i = 0; i < parametersToSend.Count; i++)
            {
                MySqlParameter p = parametersToSend[i];
                nullMap[i] = (p.Value == DBNull.Value || p.Value == null) ||
                             p.Direction == ParameterDirection.Output;
                if (nullMap[i])
                {
                    continue;
                }
                packet.Encoding = p.Encoding;
                p.Serialize(packet, true, Connection.Settings);
            }
            if (nullMap != null)
            {
                ToByteArray(nullMap, packet.Buffer, nullMapPosition);
            }

            executionCount++;

            Driver.ExecuteStatement(packet);
        }