public IInternalState New(IAdfQuery query)
{
if (query == null) return NullInternalState.Null;
var result = new DataSet { EnforceConstraints = false };
IDbConnection connection = Provider.GetConnection(DataSource);
IDbDataAdapter da = Provider.GetAdapter();
try
{
if (connection.State == ConnectionState.Closed) connection.Open();
da.TableMappings.Add("Table", query.LeadTable());
IDbCommand command = Provider.GetCommand(DataSource, connection, query);
da.SelectCommand = command;
result.Load(command.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly), LoadOption.OverwriteChanges, query.LeadTable());
result.Tables[0].Rows.Add(result.Tables[0].NewRow());
}
catch (Exception exception)
{
Provider.HandleException(exception, DataSource, query);
}
finally
{
if (connection.State == ConnectionState.Open) connection.Close();
}
return IsResultEmpty(result) ? NullInternalState.Null : RowState.New(result.Tables[0].Rows[0]);
}