I have a project that is based on RavenDB and now needs a CMS frontend. Starting with the IEntitiesRepository from the RavenDB branch I implemented IRepository and passed it into my ContentHandler.
I have a ContentType (Player) which inherits a ContentPart (PlayerPart). PlayerPart currently only contains a single property: Name. When I attempt to create a Player through the admin menu I get a notification that "Your Player has been created"
as well as "The page you are looking for does not exist".
public PlayerHandler(IEntitiesRepository<PlayerRecord> repository)
Using breakpoints I can see that my version of Create is being called when I submit the form and stepping through the code reveals that the PlayerPart.Name property is being set in UpdateEditor.
However, looking in the log file reveals what looks to be an error on the transaction, but I don't know where I would start to resolve it...
Orchard.ContentManagement.DefaultContentManager - TransactionException thrown from IContentHandler by ST.Handlers.PlayerHandler
System.Transactions.TransactionException: The operation is not valid for the state of the transaction. ---> System.Transactions.TransactionPromotionException: There was an error promoting the transaction to a distributed transaction.
at System.Transactions.TransactionStatePSPEOperation.PSPEPromote(InternalTransaction tx)
at System.Transactions.TransactionStateDelegatedBase.EnterState(InternalTransaction tx)
--- End of inner exception stack trace ---
at System.Transactions.TransactionState.EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
at System.Transactions.EnlistableStates.EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
at System.Transactions.Transaction.EnlistDurable(Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)
at Raven.Client.Document.InMemoryDocumentSessionOperations.TryEnlistInAmbientTransaction() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 877
at Raven.Client.Document.InMemoryDocumentSessionOperations.PrepareForSaveChanges() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 776
at Raven.Client.Document.DocumentSession.SaveChanges() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\DocumentSession.cs:line 434
at Orchard.Entities.EntitiesRepository`1.Create(T entity) in C:\Users\admin\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\Entities\EntitiesRepository.cs:line 123
at Orchard.Entities.EntitiesRepository`1.Orchard.Data.IRepository.Create(T entity) in C:\Users\admin\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\Entities\EntitiesRepository.cs:line 41
at Orchard.ContentManagement.Handlers.StorageFilter`1.CreateRecordCore(ContentItemVersionRecord versionRecord, TRecord record) in C:\Users\admin\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\ContentManagement\Handlers\StorageFilter.cs:line 35
at Orchard.ContentManagement.Handlers.StorageFilter`1.Creating(CreateContentContext context, ContentPart`1 instance) in C:\Users\admin\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\ContentManagement\Handlers\StorageFilter.cs:line 49
at Orchard.ContentManagement.Handlers.StorageFilterBase`1.Orchard.ContentManagement.Handlers.IContentStorageFilter.Creating(CreateContentContext context) in C:\Users\admin\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\ContentManagement\Handlers\StorageFilterBase.cs:line 36
at Orchard.ContentManagement.Handlers.ContentHandler.Orchard.ContentManagement.Handlers.IContentHandler.Creating(CreateContentContext context) in C:\Users\admin\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\ContentManagement\Handlers\ContentHandler.cs:line 220
at Orchard.ContentManagement.DefaultContentManager.<>c__DisplayClass58.b__54(IContentHandler handler) in C:\Users\admin\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 476
at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in C:\Users\admin\Documents\Visual Studio 2010\Projects\Orchard\src\Orchard\InvokeExtensions.cs:line 19
Any insight or ideas would be greatly appreciated!
I have been trying to resolve this issue for a couple of days and it is looking increasingly grim. I know that RavenDB is not support out of the box, but there are discussions that seem to imply that creating your own IRepository implementation would
allow a custom module to use RavenDB. However, I have an instance of IRepository for Raven, but I am still running into issues.
The deeper I dig through the Orchard source the more clear it becomes that perhaps creating an IRepository is only part of the story. Has anyone else had any luck creating a custom data access layer that is not tied to SQLCE or MSSQL and can function
natively with Handers/Drivers? (By natively I mean that I want to be able to pass my RavenRepository to a StorageFilter in my Handler.) Or am I looking down a long dark rabbit hole?
Jul 23, 2012 at 11:36 AM
I disagree that creating your own IRepository implementation is that way to go. I would act at the handler and driver level instead. I would not have a repository at all: having one would only confuse ContentManager into thinking this is an actual database-bound