in MySQL.Data/src/X/Sessions/XInternalSession.cs [878:1008]
public int PrepareStatement<TResult, TDoc>(BaseStatement<TResult, TDoc> statement)
where TResult : BaseResult
{
int stmtId = Interlocked.Increment(ref _stmtId);
string stmtType = statement.GetType().Name;
if (stmtType == typeof(FindStatement<>).Name)
{
FindStatement<TDoc> fs = statement as FindStatement<TDoc>;
string s = typeof(TDoc).Name;
Debug.Assert(fs != null);
_protocol.SendPrepareStatement(
(uint)stmtId,
DataAccess.PreparedStatementType.Find,
fs.Target.Schema.Name,
fs.Target.Name,
false,
fs.FilterData,
fs.findParams);
}
else if (stmtType == typeof(TableSelectStatement).Name)
{
TableSelectStatement ss = statement as TableSelectStatement;
Debug.Assert(ss != null);
_protocol.SendPrepareStatement(
(uint)stmtId,
DataAccess.PreparedStatementType.Find,
ss.Target.Schema.Name,
ss.Target.Name,
true,
ss.FilterData,
ss.findParams);
}
else if (stmtType == typeof(ModifyStatement<>).Name)
{
ModifyStatement<TDoc> ms = statement as ModifyStatement<TDoc>;
Debug.Assert(ms != null);
_protocol.SendPrepareStatement(
(uint)stmtId,
DataAccess.PreparedStatementType.Update,
ms.Target.Schema.Name,
ms.Target.Name,
false,
ms.FilterData,
null,
ms.Updates);
}
else if (stmtType == typeof(TableUpdateStatement).Name)
{
TableUpdateStatement us = statement as TableUpdateStatement;
Debug.Assert(us != null);
_protocol.SendPrepareStatement(
(uint)stmtId,
DataAccess.PreparedStatementType.Update,
us.Target.Schema.Name,
us.Target.Name,
true,
us.FilterData,
null,
us.updates);
}
else if (stmtType == typeof(RemoveStatement<>).Name)
{
string s = typeof(TDoc).Name;
RemoveStatement<TDoc> rs = statement as RemoveStatement<TDoc>;
Debug.Assert(rs != null);
_protocol.SendPrepareStatement(
(uint)stmtId,
DataAccess.PreparedStatementType.Delete,
rs.Target.Schema.Name,
rs.Target.Name,
false,
rs.FilterData,
null);
}
else if (stmtType == typeof(TableDeleteStatement).Name)
{
TableDeleteStatement ds = statement as TableDeleteStatement;
Debug.Assert(ds != null);
_protocol.SendPrepareStatement(
(uint)stmtId,
DataAccess.PreparedStatementType.Delete,
ds.Target.Schema.Name,
ds.Target.Name,
true,
ds.FilterData,
null);
}
else if (stmtType == typeof(TableInsertStatement).Name)
{
TableInsertStatement insert = statement as TableInsertStatement;
Debug.Assert(insert != null);
_protocol.SendPrepareStatement(
(uint)stmtId,
DataAccess.PreparedStatementType.Insert,
insert.Target.Schema.Name,
insert.Target.Name,
true,
null,
null,
null,
insert.values.ToArray(),
insert.fields,
false);
}
else if (stmtType == typeof(SqlStatement).Name)
{
SqlStatement sqlStatement = statement as SqlStatement;
Debug.Assert(sqlStatement != null);
_protocol.SendPrepareStatement(
(uint)stmtId,
DataAccess.PreparedStatementType.SqlStatement,
null,
null,
true,
null,
null,
null,
sqlStatement.parameters.ToArray(),
null,
false,
sqlStatement.SQL);
}
else
{
throw new NotSupportedException(statement.GetType().Name);
}
_preparedStatements.Add(stmtId);
return stmtId;
}