London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Items not persisting in Dynamic Datastore

Vote:
 

Hi,

I am adding objects to a DDS, and I get a new Identity returned when doing so, indicating it was added. 
However, when I've completed adding my items, and go to get a count of items in hte store, it is always returning "0" results:

My code is as follows:

 

            if (DynamicDataStoreFactory.Instance.GetStore(language) == null)
            {
                DynamicDataStoreFactory.Instance.CreateStore(language, typeof(ExportPageSimple));
            }

            foreach (var page in pagesSimple)
            {
                if (DynamicDataStoreFactory.Instance.GetStore(language).LoadAll<ExportPageSimple>().Any(i => i.PageGuid == page.PageGuid))
                {
                    DynamicDataStoreFactory.Instance.GetStore(language).Delete(page);
                }

                var id = DynamicDataStoreFactory.Instance.GetStore(language).Save(page);
            }

            var itemCount = DynamicDataStoreFactory.Instance.GetStore(language).LoadAll().Count();

    

The language string is not null, same for the page object being saved. The itemCount int is always 0, dispite the .Save being hit several times. 

Any ideas?

#77597
Nov 21, 2013 11:55
Vote:
 

Try with:

var store = typeof(language).GetStore();
store.Save(mylanguageObject);
var items = store.Items<language>();

var count = items.Count();

Frederik    

#77598
Nov 21, 2013 12:34
Vote:
 

Thanks for the response Frederik,

I needed to have separate Data stores for different languages, as the Ids of the items I was adding were based on page Id's and hence the same..

I've changed my code now to store a single object, which it self has child elements with the language specified

I am able to retrieve the object, update it, and re save it with out issue.

Cheers
Danny

#77607
Nov 21, 2013 14:37
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.