I was doing tests regarding transactions and I saw that if I conduct a search of the registered and uncommitted data they are returned. In the entity framework this does not happen, and from what I researched behind the scenes he works with transactions.
Someone knows how I can get around this:
var conn = new SqlConnection(ConfigurationManager.
ConnectionStrings["connNorthwind"].ConnectionString);
conn.Open();
var transaction = conn.BeginTransaction();
string productName = "tEST1";
var commad1 = conn.CreateCommand();
commad1.Transaction = transaction;
var commad2 = conn.CreateCommand();
commad2.Transaction = transaction;
var commad3 = conn.CreateCommand();
commad3.Transaction = transaction;
commad1.CommandText = "INSERT products(ProductName, Discontinued)VALUES ('" + productName + "', 'true')";
commad1.ExecuteNonQuery();
commad2.CommandText = "INSERT products(ProductName, Discontinued)VALUES ('" + productName + "', 'true')";
commad2.ExecuteNonQuery();
commad3.CommandText = "SELECT * FROM products where ProductName like '%" + productName + "%'";
var reader = commad3.ExecuteReader(System.Data.CommandBehavior.SingleResult);
bool produtoExistente = false;
if (reader.HasRows)
{
produtoExistente = true;
}
Assert.IsFalse(produtoExistente);