I'm using Umbraco 7.7.6, I've recently upgraded from 7.5.13.
I've created a class called UnitOfWork which is used as a container for the instance of Database. This all seemed to work on 7.5.13 but doesn't seem to like creating a new transaction on the latest version.
Calling the database works, it just throws a null exception when creating a transaction.
private readonly Database _db;
public UnitOfWork(Database db)
{
_db = db;
}
public Transaction GetTransaction()
{
return _db.GetTransaction();
}
Error:
at Umbraco.Core.Persistence.Database.BeginTransaction(IsolationLevel isolationLevel)
at Umbraco.Core.Persistence.Database.GetTransaction()
at CMS.Library.DataAccess.UnitOfWork.GetTransaction() in \\CMS.Library\DataAccess\Implementation\UnitOfWork.cs:line 330
at CMS.Library.Services.ProductService.Save(ProductViewModel productViewModel) in \\Services\ProductService.cs:line 254
Okay so I fixed it, but I feel like it's wrong. Here's the registry:
For<Database>().Use(() => new Database("umbracoDbDSN")).Transient();
For<IUnitOfWork>().Use<UnitOfWork>()
.Ctor<Database>().Is(() => new Database("umbracoDbDSN"));
Database.GetTransaction Throws Null Exception
Hi All
I'm using Umbraco 7.7.6, I've recently upgraded from 7.5.13.
I've created a class called UnitOfWork which is used as a container for the instance of Database. This all seemed to work on 7.5.13 but doesn't seem to like creating a new transaction on the latest version.
Calling the database works, it just throws a null exception when creating a transaction.
Code as follows.
DefaultRegistry (I'm using StructureMap):
UnitOfWork.cs:
Error:
Thanks
Okay so I fixed it, but I feel like it's wrong. Here's the registry:
is working on a reply...