mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding a way to configure the isolation level
This commit is contained in:
31
src/Orchard.Azure/Orchard.Azure.Web/Config/Sites.config
Normal file
31
src/Orchard.Azure/Orchard.Azure.Web/Config/Sites.config
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<configSections>
|
||||||
|
<section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration"/>
|
||||||
|
</configSections>
|
||||||
|
|
||||||
|
<autofac defaultAssembly="Orchard.Framework">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
To create tenant specific configurations, copy this file to ~/Congig/Sites.{tenant}.config
|
||||||
|
where {tenant} is the technical name of the targetted tenant
|
||||||
|
-->
|
||||||
|
<components>
|
||||||
|
<!--
|
||||||
|
Uncomment to use ReadUncommitted as the default isolation level. Please not that
|
||||||
|
Sql Server Ce doesn't support ReadUncommitted.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
<component instance-scope="per-lifetime-scope"
|
||||||
|
type="Orchard.Data.SessionLocator, Orchard.Framework"
|
||||||
|
service="Orchard.Data.ISessionLocator">
|
||||||
|
<properties>
|
||||||
|
<property name="IsolationLevel" value="ReadUncommitted" />
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
-->
|
||||||
|
</components>
|
||||||
|
</autofac>
|
||||||
|
|
||||||
|
</configuration>
|
@@ -209,6 +209,7 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Config\Sites.config" />
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>Web.config</DependentUpon>
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
31
src/Orchard.Web/Config/Sites.config
Normal file
31
src/Orchard.Web/Config/Sites.config
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<configSections>
|
||||||
|
<section name="autofac" type="Autofac.Configuration.SectionHandler, Autofac.Configuration"/>
|
||||||
|
</configSections>
|
||||||
|
|
||||||
|
<autofac defaultAssembly="Orchard.Framework">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
To create tenant specific configurations, copy this file to ~/Congig/Sites.{tenant}.config
|
||||||
|
where {tenant} is the technical name of the targetted tenant
|
||||||
|
-->
|
||||||
|
<components>
|
||||||
|
<!--
|
||||||
|
Uncomment to use ReadUncommitted as the default isolation level. Please not that
|
||||||
|
Sql Server Ce doesn't support ReadUncommitted.
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
|
<component instance-scope="per-lifetime-scope"
|
||||||
|
type="Orchard.Data.SessionLocator, Orchard.Framework"
|
||||||
|
service="Orchard.Data.ISessionLocator">
|
||||||
|
<properties>
|
||||||
|
<property name="IsolationLevel" value="ReadUncommitted" />
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
-->
|
||||||
|
</components>
|
||||||
|
</autofac>
|
||||||
|
|
||||||
|
</configuration>
|
@@ -157,6 +157,7 @@
|
|||||||
<Content Include="Config\Host.config" />
|
<Content Include="Config\Host.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Config\Sites.config" />
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>Web.config</DependentUpon>
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
@@ -24,9 +24,11 @@ namespace Orchard.Data {
|
|||||||
_sessionFactoryHolder = sessionFactoryHolder;
|
_sessionFactoryHolder = sessionFactoryHolder;
|
||||||
_interceptors = interceptors;
|
_interceptors = interceptors;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
|
IsolationLevel = IsolationLevel.ReadCommitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILogger Logger { get; set; }
|
public ILogger Logger { get; set; }
|
||||||
|
public IsolationLevel IsolationLevel { get; set; }
|
||||||
|
|
||||||
public ISession For(Type entityType) {
|
public ISession For(Type entityType) {
|
||||||
Logger.Debug("Acquiring session for {0}", entityType);
|
Logger.Debug("Acquiring session for {0}", entityType);
|
||||||
@@ -41,12 +43,12 @@ namespace Orchard.Data {
|
|||||||
|
|
||||||
if (_transaction == null) {
|
if (_transaction == null) {
|
||||||
Logger.Debug("Creating transaction on Demand");
|
Logger.Debug("Creating transaction on Demand");
|
||||||
_transaction = _session.BeginTransaction(IsolationLevel.ReadCommitted);
|
_transaction = _session.BeginTransaction(IsolationLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequireNew() {
|
public void RequireNew() {
|
||||||
RequireNew(IsolationLevel.ReadCommitted);
|
RequireNew(IsolationLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequireNew(IsolationLevel level) {
|
public void RequireNew(IsolationLevel level) {
|
||||||
|
Reference in New Issue
Block a user