単体テストを実行していますが、データベースにデータを挿入してすぐに取得しようとすると、何も得られません ( DataAdapter
and で試しましたDataReader
)。
ただし、挿入と選択の間に3秒のスリープ(1秒でも機能しません...)を置くと、結果が得られます。
SQL Server Profiler で実行を確認できます。挿入は適切に行われ、選択が開始される約 10 ミリ秒前に完了します。
これがどこに来るのかわかりません
コードは次のようになります: Insert メソッド
SqlCommand command = new SqlCommand(sqlTemplate);
command.Parameters.Add(Sql4oConstants.Sql4oIdParameterName, SqlDbType.UniqueIdentifier).Value = id;
command.Parameters.Add(Sql4oConstants.Sql4oTimestampParamterName, SqlDbType.DateTime).Value = DateTime.Now;
command.CommandTimeout = dataSourceDescription.CommandTimeout;
DatabaseManager.ExecuteNonQuery(dataSourceDescription.ConnectionString, command);
メソッドを取得
public static void Fill(string connectionString, DataTable table, SqlCommand command)
{
try
{
LogStorageWriter.WriteLogEntry(log, EStorageLevelLog.Debug, string.Format("Execute query: {0}", command.CommandText));
using (SqlConnection conn = new SqlConnection(connectionString))
{
command.Connection = conn;
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
adapter.Fill(table);
}
}
}
catch (InvalidOperationException e)
{
LogStorageWriter.WriteLogEntry(log, EStorageLevelLog.Error, string.Format("Exception : {0}", e.ToString()));
}
}