Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit e46def2

Browse files
committed
Allow DbFactory to be injected manually
1 parent 748e21b commit e46def2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ServiceStack.OrmLite/TemplateDbFilters.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ namespace ServiceStack.OrmLite
88
{
99
public class TemplateDbFilters : TemplateFilter
1010
{
11+
private IDbConnectionFactory dbFactory;
12+
public IDbConnectionFactory DbFactory
13+
{
14+
get => dbFactory ?? (dbFactory = Context.Container.Resolve<IDbConnectionFactory>());
15+
set => dbFactory = value;
16+
}
17+
1118
T exec<T>(Func<IDbConnection, T> fn, TemplateScopeContext scope, object options)
1219
{
1320
try
1421
{
15-
using (var db = Context.Container.Resolve<IDbConnectionFactory>().Open())
22+
using (var db = DbFactory.Open())
1623
{
1724
return fn(db);
1825
}

0 commit comments

Comments
 (0)