Store media in MS SQL database

Topics: General
Apr 18, 2012 at 2:37 AM

Hi all,

We wish to run our site on several load-balanced servers. Is it possible to store media files in a MS SQL database instead of the file system?

Thanks,
Chris 

Coordinator
Apr 25, 2012 at 3:10 PM

Hi Chris

We don't have this functionality implemented. The media provider logic is pluggable and is it possible to write own version of MediaFileProvider class that would do it. You also may consider using our Windows Azure Publisher

Apr 25, 2012 at 3:18 PM

you could also maybe use a shared directory and change the location, as was discussed here Using MediaHandler for files outside app_data\media folder?

Feb 14, 2013 at 4:52 PM
Hello @napernik / @burningice,

How could i implement the MediaFileProvider approach?

I don´t see in the web.config a config for this.

I must create a class to implement the provider and hoy i tell composite to use it? Only with this provider composite will work with media in DB, also in the media layout in console?

How do you think the table to alloc this data must be? Can i use the C1 DataFacade or LinqToSQL directly?

Regards!
Feb 18, 2013 at 11:53 AM
Instead of using a shared directory for the media, across the servers, what about using the Windows Resource Kit command-line program Robocopy, in "mirror" mode? It might be an easier approach to cloning files within the media directory across all of the load-balance servers.
Feb 18, 2013 at 5:48 PM
Hello,

My problem is that the same intranet must run in to separate servers because will be used by to diferent companies under diferent domains, but the data must be the same.

I am trying to implement a mediaProvider, i created some classes using the FacebookMediaProvider as example. I created this clases in the App_Code folder. I don't know how to reference this provider in de composite.config file. This classes must be in a separate dll?

also for simplicity i did't created a DB type from code, i used the Data perspective, so i think i can't move all to a separate dll straihgt forward.

Regards!
Coordinator
Feb 18, 2013 at 11:39 PM
Quick tip: To move a data type from "design mode" to "code" take a look at Composite.Tools.StaticDataTypeCreator - makes it a lot easier.
Feb 25, 2013 at 1:29 PM
Hello,

Thanks, the link gives me a 404 error.

I this one? http://www.composite.net/Add-on-Market/Packages/Composite.Tools.StaticDataTypeCreator/Installation

This package creates something portable to use in a dll?

I don´t know if i have to put my plugin files in a DLL or i can reference my plugin directly from inside the c1 project.

Regards,

mawtex wrote:
Quick tip: To move a data type from "design mode" to "code" take a look at Composite.Tools.StaticDataTypeCreator - makes it a lot easier.
Coordinator
Feb 25, 2013 at 2:01 PM
We ported all package info from our docs site to the add-on market - sorry about the 404, we will get that fixed.

The package will give you the source code for a data type you created via the visual tools and the guidance on the page should desctibe how you can transition from a "dynamic data type" to a "static data type".

You don't have to move your data types to code, but I would recommend it. You are not dependent on the type that Composite C1 auto generate and put in Composite.Generated.dll.
I don´t know if i have to put my plugin files in a DLL or i can reference my plugin directly from inside the c1 project.
What exactly are you building? Typically plug-ins are packaged in assemblies (they are DLL files) you drop into ~/bin and (often) register in Composite.config.

Anyway, my suggestion to put your data type into code was mostly motivated by that you are building a media data provider and you use data types to store meta data out your media. In such a setup, where you have a media data provider (which is a code based plug-in you copy to bin) it makes a lot of sense that you have the data types in code also, so your plug-in will 'bring its own stuff to the table'.
Feb 25, 2013 at 2:31 PM
Ok, thanks!

I am creating my provider classes in the APP_Code folder for simplicity (i am new at composite).

My questions were about the provider creation (to store media in DB), a summary:

1- Can i create my provider in the APP_Code folder of the composite site i am building?
2- If i can, how do i reference this provider in composite.config file?
Now the config is:
<add rootDirectory="~/App_Data/Media" storeId="MediaArchive" storeDescription="Media Archive Files" storeTitle="Media Archive" type="Composite.Plugins.Data.DataProviders.MediaFileProvider.MediaFileProvider, Composite, Version=1.0.3037.13741, Culture=neutral, PublicKeyToken=null" name="MediaFileDataProvider" />
I think could be something like this?:
type="Composite.Plugins.Data.DataProviders.MediaFileProvider.MyDBProvider, Website(???), Version=(???), Culture=neutral, PublicKeyToken=null"
(I know this is more a .net thing).
3- The static datatype that you recomend is to give me more control over columns types? Or there are another PROs?

Thanks!


mawtex wrote:
We ported all package info from our docs site to the add-on market - sorry about the 404, we will get that fixed.

The package will give you the source code for a data type you created via the visual tools and the guidance on the page should desctibe how you can transition from a "dynamic data type" to a "static data type".

You don't have to move your data types to code, but I would recommend it. You are not dependent on the type that Composite C1 auto generate and put in Composite.Generated.dll.
I don´t know if i have to put my plugin files in a DLL or i can reference my plugin directly from inside the c1 project.
What exactly are you building? Typically plug-ins are packaged in assemblies (they are DLL files) you drop into ~/bin and (often) register in Composite.config.

Anyway, my suggestion to put your data type into code was mostly motivated by that you are building a media data provider and you use data types to store meta data out your media. In such a setup, where you have a media data provider (which is a code based plug-in you copy to bin) it makes a lot of sense that you have the data types in code also, so your plug-in will 'bring its own stuff to the table'.
Coordinator
Feb 25, 2013 at 2:44 PM
1 - Yes. It should work (unless 3)
2 - The syntax is type="Composite.Plugins.Data.DataProviders.MediaFileProvider.MyDBProvider, App_Code"
3 - if you are going to create some auto generated types (like Composite.Generated.dll), you won't be able to reference App_Code from /bin/*.dll
Feb 25, 2013 at 4:39 PM
Edited Feb 25, 2013 at 4:40 PM
Hello!

Thanks for you reply.

I didn't understand the 3rd one. I am calling the facade with generated type ok, for this provider and others things used in the intranet i am building.

Other problem i am having:

I changed the composite.config file as you said and know my provider is being called.

But, when i go to the media console after opening 2 nodes i am getting an exception about a MediaFileProviderElementProvider Provider:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , IMediaFileFolder )
at System.Linq.Enumerable.WhereListIterator1.MoveNext()
at System.Linq.Buffer
1..ctor(IEnumerable1 source)
at System.Linq.OrderedEnumerable
1.<GetEnumerator>d__0.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Collections.Generic.List
1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)
at Composite.Plugins.Elements.ElementProviders.MediaFileProviderElementProvider.MediaFileProviderElementProvider.GetChildrenOnPath(String parentPath, String storeId, SearchToken searchToken)
at Composite.Plugins.Elements.ElementProviders.MediaFileProviderElementProvider.MediaFileProviderElementProvider.GetChildren(EntityToken entityToken, SearchToken searchToken)
at Composite.C1Console.Elements.Foundation.PluginFacades.ElementProviderPluginFacade.GetChildren(String providerName, EntityToken entityToken, SearchToken seachToken)
at Composite.C1Console.Elements.ElementFacade.GetChildren(ElementHandle elementHandle, SearchToken searchToken, Boolean performSecurityCheck, Boolean useForeign)
at Composite.C1Console.Elements.ElementFacade.GetChildren(ElementHandle elementHandle, SearchToken searchToken)
at Composite.Core.WebClient.FlowMediators.TreeServicesFacade.GetChildren(String providerName, String serializedEntityToken, String piggybag, String serializedSearchToken)
at Composite.Services.TreeServices.GetElementsBySearchToken(ClientElement clientElement, String serializedSearchToken) in e:\Proyectos\RSA V2\Website\Composite\services\Tree\TreeServices.asmx:line 144
at Composite.Services.TreeServices.GetElements(ClientElement clientElement) in e:\Proyectos\RSA V2\Website\Composite\services\Tree\TreeServices.asmx:line 84
--- End of inner exception stack trace ---

Do i have to implement this class? Or is something i am doing bad?

Regards!


napernik wrote:
1 - Yes. It should work (unless 3)
2 - The syntax is type="Composite.Plugins.Data.DataProviders.MediaFileProvider.MyDBProvider, App_Code"
3 - if you are going to create some auto generated types (like Composite.Generated.dll), you won't be able to reference App_Code from /bin/*.dll
Feb 25, 2013 at 6:13 PM
Sorry, this is the error: (i wasn't returning a value for directories in the GetData method in the provider).

The GetData returns a List of
internal sealed class DBMediaFileFolder : IMediaFileFolder
or
[FileStreamManager(typeof(DBFileStreamManager))]
public sealed class DBMediaFile : FileSystemFileBase, IMediaFile
or a Store

But i am having this error in the TreeService:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NotSupportedException: Method 'Composite.Plugins.Data.DataProviders.DBMediaFileProvider.DBMediaFile CreateFile(Composite.Media.DBMediaFile)' has no supported translation to SQL.
at System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitMethodCall(SqlMethodCall mc)
at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
at System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp)
at System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitMember(SqlMember m)
at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
at System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp)
at System.Data.Linq.SqlClient.SqlVisitor.VisitBinaryOperator(SqlBinary bo)
at System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitBinaryOperator(SqlBinary bo)
at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
at System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp)
at System.Data.Linq.SqlClient.SqlVisitor.VisitBinaryOperator(SqlBinary bo)
at System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitBinaryOperator(SqlBinary bo)
at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
at System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp)
at System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select)
at System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitSelect(SqlSelect select)
at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
at System.Data.Linq.SqlClient.SqlProvider.BuildQuery(ResultShape resultShape, Type resultType, SqlNode node, ReadOnlyCollection1 parentParameters, SqlNodeAnnotations annotations)
at System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery
1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at Composite.Data.Foundation.DataFacadeQueryable1.GetEnumerator()
at Composite.Data.Foundation.DataFacadeQueryable
1.GetEnumerator()
at Composite.Data.Types.StoreIdFilter.StoreIdFilterQueryable1.GetEnumerator()
at System.Collections.Generic.List
1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)
at Composite.Plugins.Elements.ElementProviders.MediaFileProviderElementProvider.MediaFileProviderElementProvider.GetChildrenOnPath(String parentPath, String storeId, SearchToken searchToken)
at Composite.Plugins.Elements.ElementProviders.MediaFileProviderElementProvider.MediaFileProviderElementProvider.GetChildren(EntityToken entityToken, SearchToken searchToken)
at Composite.C1Console.Elements.Foundation.PluginFacades.ElementProviderPluginFacade.GetChildren(String providerName, EntityToken entityToken, SearchToken seachToken)
at Composite.C1Console.Elements.ElementFacade.GetChildren(ElementHandle elementHandle, SearchToken searchToken, Boolean performSecurityCheck, Boolean useForeign)
at Composite.C1Console.Elements.ElementFacade.GetChildren(ElementHandle elementHandle, SearchToken searchToken)
at Composite.Core.WebClient.FlowMediators.TreeServicesFacade.GetChildren(String providerName, String serializedEntityToken, String piggybag, String serializedSearchToken)
at Composite.Services.TreeServices.GetElementsBySearchToken(ClientElement clientElement, String serializedSearchToken) in e:\Proyectos\RSA V2\Website\Composite\services\Tree\TreeServices.asmx:line 144
at Composite.Services.TreeServices.GetElements(ClientElement clientElement) in e:\Proyectos\RSA V2\Website\Composite\services\Tree\TreeServices.asmx:line 84
--- End of inner exception stack trace ---
Coordinator
Feb 25, 2013 at 10:30 PM
napernik is the ninja on this subject, but sounds like you have a LINQ query somewhere where you call a function named CreateFile() and this upsets LINQ for SQL.

As an example of something similar look at this sample myQueryable.Where( f=> f.Id == GetCoolId() ) - LINQ for SQL will try to transform the predicate into a SQL WHERE sentence and this will fail, since this sample is using GetCoolId() which LINQ for SQL have no clue about.

So I'm guessing you need to locate the offending LINQ statement where you call CreateFile() and get it out somehow.

And a small plea: please don't use the "Composite" namespace for your own code - makes it really hard to see if it is our code or user code that is failing.
Feb 26, 2013 at 1:24 PM
Thanks for all responses!

It is starting to work.

I will change namespaces. I copied the base code, rewrited it and started testing. I will refactor all when complete.

I thought the exceptions where caused because i would need to implement another provider. When the errors started changing i realized it was my problem, so sorry for posting them :)

Best regards!
Feb 26, 2013 at 5:47 PM
Sorry all my msgs!

Last: The provider is almost working. I can add and delete folders and files. The only thing i couldn't resolve is de "cut and paste".

I have two diferent exceptions comming from TreeServices.asmx

One when i try to move a file and other when i try to move a folder.

When i move a folder it pases throw the Update method in the provider, the update in Database is OK but then in treeServices when the SubmitChanges is made i get an exception:

Sorry, i didn't change the namespaces yet
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.ChangeDirector.StandardChangeDirector.DynamicUpdate(TrackedObject item)
at System.Data.Linq.ChangeDirector.StandardChangeDirector.Update(TrackedObject item)
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges()
at Composite.Plugins.Data.DataProviders.MSSqlServerDataProvider.SqlDataTypeStoresContainer.SubmitChanges(DataContext dataContext)
at Composite.Plugins.Data.DataProviders.MSSqlServerDataProvider.SqlDataTypeStoresContainer.Update(IEnumerable1 dataset)
at Composite.Plugins.Data.DataProviders.MSSqlServerDataProvider.SqlDataProvider.Update(IEnumerable
1 datas)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.<>c__DisplayClassc.<Update>b__a(IWritableDataProvider provider)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.<>c__DisplayClass1a1.<SyncronizedCall>b__19(TProvider provider)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.SyncronizedCall[TProvider,TResult](String providerName, SyncronizedCallDelegate
2 func)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.SyncronizedCall[TProvider](String providerName, SyncronizedCallDelegate1 func)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.Update(String providerName, IEnumerable
1 dataset)
at Composite.Data.DataFacadeImpl.Update(IEnumerable1 dataset, Boolean suppressEventing, Boolean performForeignKeyIntegrityCheck, Boolean performeValidation)
at Composite.Data.DataFacade.Update(IEnumerable
1 dataset)
at Composite.Data.DataFacade.Update(IData data)
at Composite.Core.Implementation.DataConnectionImplementation.Update[TData](TData item)
at Composite.Data.DataConnection.Update[TData](TData item)
at Composite.Plugins.Data.DataProviders.DBMediaFileProvider.DBMediaFileFacade.MoveDir(String oldFolder, String newFolder) in e:\Proyectos\RSA V2\Website\App_Code\Composite\Plugins\DBMediaFileFacade.cs:line 109
at Composite.Plugins.Data.DataProviders.DBMediaFileProvider.DBMediaFileProvider.Update(IEnumerable1 datas) in e:\Proyectos\RSA V2\Website\App_Code\Composite\Plugins\DBMediaFileProvider.cs:line 124
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.<>c__DisplayClassc.<Update>b__a(IWritableDataProvider provider)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.<>c__DisplayClass1a
1.<SyncronizedCall>b__19(TProvider provider)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.SyncronizedCall[TProvider,TResult](String providerName, SyncronizedCallDelegate2 func)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.SyncronizedCall[TProvider](String providerName, SyncronizedCallDelegate
1 func)
at Composite.Data.Foundation.PluginFacades.DataProviderPluginFacade.Update(String providerName, IEnumerable1 dataset)
at Composite.Data.DataFacadeImpl.Update(IEnumerable
1 dataset, Boolean suppressEventing, Boolean performForeignKeyIntegrityCheck, Boolean performeValidation)
at Composite.Data.DataFacade.Update(IEnumerable`1 dataset)
at Composite.Data.DataFacade.Update(IData data)
at Composite.Plugins.Elements.ElementProviders.MediaFileProviderElementProvider.MediaFileProviderElementProvider.OnElementDraggedAndDropped(EntityToken draggedEntityToken, EntityToken newParentEntityToken, Int32 dropIndex, DragAndDropType dragAndDropType, FlowControllerServicesContainer flowControllerServicesContainer)
at Composite.C1Console.Elements.Foundation.PluginFacades.ElementProviderPluginFacade.OnElementDraggedAndDropped(String providerName, EntityToken draggedEntityToken, EntityToken newParentEntityToken, Int32 dropIndex, DragAndDropType dragAndDropType, FlowControllerServicesContainer draggedElementFlowControllerServicesContainer)
at Composite.C1Console.Elements.ElementFacade.ExecuteElementDraggedAndDropped(ElementHandle draggedElementHandle, ElementHandle newParentElementHandle, Int32 dropIndex, Boolean isCopy, FlowControllerServicesContainer draggedElementFlowControllerServicesContainer)
at Composite.Core.WebClient.FlowMediators.ActionExecutionMediator.ExecuteElementDraggedAndDropped(ElementHandle draggedElementHandle, ElementHandle newParentdElementHandle, Int32 dropIndex, String consoleId, Boolean isCopy)
at Composite.Core.WebClient.FlowMediators.TreeServicesFacade.ExecuteElementDraggedAndDropped(String draggedElementProviderName, String draggedElementSerializedEntityToken, String draggedElementPiggybag, String newParentElementProviderName, String newParentElementSerializedEntityToken, String newParentElementPiggybag, Int32 dropIndex, String consoleId, Boolean isCopy)
at Composite.Services.TreeServices.ExecuteDropElementAction(ClientElement draggedClientElement, ClientElement newParentClientElement, Int32 dropIndex, String consoleId, Boolean isCopy) in e:\Proyectos\RSA V2\Website\Composite\services\Tree\TreeServices.asmx:line 237
Then when moving a file, it doesn't goes throw the Update method, but the TreeServices in the drag and drop throws an exception of invalid cast (it is trying to cast from my class Composite.Plugins.Data.DataProviders.DBMediaFileProvider.DBMediaFile: IFile to the Composite.Media.DBMediaFile type that is mapped to the database table):
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentException: Object of type 'Composite.Plugins.Data.DataProviders.DBMediaFileProvider.DBMediaFile' cannot be converted to type 'Composite.Media.DBMediaFile'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Composite.Data.Validation.ValidationFacadeImpl.Validate(Type interfaceType, IData data)
at Composite.Data.Validation.ValidationFacade.Validate(Type interfaceType, IData data)
at Composite.Data.Validation.ValidationFacade.Validate(IData data)
at Composite.Data.DataFacadeImpl.Update(IEnumerable1 dataset, Boolean suppressEventing, Boolean performForeignKeyIntegrityCheck, Boolean performeValidation)
at Composite.Data.DataFacade.Update(IEnumerable
1 dataset)
at Composite.Data.DataFacade.Update(IData data)
at Composite.Plugins.Elements.ElementProviders.MediaFileProviderElementProvider.MediaFileProviderElementProvider.OnElementDraggedAndDropped(EntityToken draggedEntityToken, EntityToken newParentEntityToken, Int32 dropIndex, DragAndDropType dragAndDropType, FlowControllerServicesContainer flowControllerServicesContainer)
at Composite.C1Console.Elements.Foundation.PluginFacades.ElementProviderPluginFacade.OnElementDraggedAndDropped(String providerName, EntityToken draggedEntityToken, EntityToken newParentEntityToken, Int32 dropIndex, DragAndDropType dragAndDropType, FlowControllerServicesContainer draggedElementFlowControllerServicesContainer)
at Composite.C1Console.Elements.ElementFacade.ExecuteElementDraggedAndDropped(ElementHandle draggedElementHandle, ElementHandle newParentElementHandle, Int32 dropIndex, Boolean isCopy, FlowControllerServicesContainer draggedElementFlowControllerServicesContainer)
at Composite.Core.WebClient.FlowMediators.ActionExecutionMediator.ExecuteElementDraggedAndDropped(ElementHandle draggedElementHandle, ElementHandle newParentdElementHandle, Int32 dropIndex, String consoleId, Boolean isCopy)
at Composite.Core.WebClient.FlowMediators.TreeServicesFacade.ExecuteElementDraggedAndDropped(String draggedElementProviderName, String draggedElementSer
*napernik wrote
Feb 27, 2013 at 2:39 AM
You're most likely iterating over a lazy-loaded IEnumerable collection, while doing new data lookups. Fix for this is usually to call .ToList() before enumerating to be sure not to keep the datareader open.

Here is an example of fixing the very same issue https://bitbucket.org/burningice/compositec1contrib/diff/Sorting/Web/UI/SortData.cs?diff2=33ffdfc48891&at=default
Feb 27, 2013 at 1:17 PM
Edited Feb 27, 2013 at 1:21 PM
Hello!

I did all the ToList() to all lookup methods but still having same 2 exceptions.

For the others methods i am calling, like "moveDirectory" that updates data on the database can i make the submitChanges and close the reader? Maybe is something like that? Or in the dispose of the connection is all solved?

Example:
 using (DataConnection connection = new DataConnection())
            {
                var subfiles = (from f in connection.Get<Composite.Media.DBMediaFile>()
                             where f.FolderPath.Contains(oldFolder + "/")
                             select f);
                
                foreach (var file in subfiles)
                {
                    file.FolderPath = newFolder;
                    connection.Update<Composite.Media.DBMediaFile>(file);
                }
}
Regards

burningice wrote:
You're most likely iterating over a lazy-loaded IEnumerable collection, while doing new data lookups. Fix for this is usually to call .ToList() before enumerating to be sure not to keep the datareader open.

Here is an example of fixing the very same issue https://bitbucket.org/burningice/compositec1contrib/diff/Sorting/Web/UI/SortData.cs?diff2=33ffdfc48891&at=default
Coordinator
Feb 27, 2013 at 7:24 PM
Edited Feb 27, 2013 at 7:25 PM
Have you tried this?
 using (DataConnection connection = new DataConnection())
 {
   var subfiles = (from f in connection.Get<Composite.Media.DBMediaFile>()
                         where f.FolderPath.Contains(oldFolder + "/")
                         select f).ToList();
                
  foreach (var file in subfiles)
  {
      file.FolderPath = newFolder;
      connection.Update<Composite.Media.DBMediaFile>(file);
    }
}
(notice the .ToList() on line 5)
Feb 27, 2013 at 7:34 PM
Hello!

Didn't change :(

Regards!