-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Look at the following operation
using(var session = Domain.OpenSession()) {
_ = session.Query.Insert(() => new TestEntity(session) { Name = "The Awesome Name" });
}
This code will work for some reason. I would expect an exception telling that transaction is required.
There is strange part in Operation
protected void EnsureTransactionIsStarted()
{
var accessor = QueryProvider.Session.Services.Demand<DirectSqlAccessor>();
var notUsed = accessor.Transaction;
}
I'm pretty sure this part relies on some check within the accessor.Transaction
property.
This property checked transaction existence long ago:
public DbTransaction Transaction {
get {
TryStartTransaction();
return service.Transaction;
}
}
private void TryStartTransaction()
{
if (Session.Transaction!=null)
Session.EnsureTransactionIsStarted();
}
but now there is no check so I think check for transaction should be recovered but within extension to force user to open TransactionScope
. Otherwise, insert will be executed in auto-commit transactions. I have a feeling that this is not how it should work.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working