Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Store media in MS SQL database

$
0
0
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

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>