Update row in DDS

Vote:
 

Hi,

Is it possible to update an existing row in the DynamicDataStore (DDS) and if so how do you do it?

Thanks

Jon

#113404
Nov 19, 2014 16:59
Vote:
 

Theoretically, yes, it's possible. But may I ask if there is any reason you can't use DDS API? We would not recommend to update DDS via SQL directly, unless you're very sure about what you're doing.

If you still want to do that, then there some tables to look into:

- tblSystemBigTable, used for system DDS, such as SiteDefinition

- tblBigTable, and related tables, for your normal DDS, check StoreName and ItemType to make sure you're updating correct store.

- custom table, as mapped in your code.

Regards.

/Q

#113421
Nov 20, 2014 2:53
Vote:
 

Hi,

Yes I wanted to use the API to update the row in the DDS such as

DynamicDataStore list = GetStore(typeof(CategoryItems));

etc but cant see away to update an existing row,

Jon

#113426
Nov 20, 2014 9:04
Vote:
 

I'm quite sure that we support saving existing row with DDS on 6R2, just load the old object, make the edit and save it back. Do you got any issues with that?

/Q

#113428
Nov 20, 2014 9:23
Vote:
 

How do you give it the ID - do you use the ID - is there any code that you can share - I have tried a number of ways but nothing seems to work.

such as:

  DynamicDataStore store = (DynamicDataStore)DynamicDataStoreFactory.Instance.GetStore(typeof(CategoryItems));
                if (store != null)
                {
                    IEnumerable<PropertyBag> landingProperties = store.FindAsPropertyBag("gId", hdngId.Value);

                    if (landingProperties != null)
                    {
                        foreach (PropertyBag item in landingProperties)
                        {

                            item["CatType"] = ddCategorylist.Value.Trim().Replace("\r\n", "").Replace("~/Templates/contactusxml/", "");
                            item["Name"] = txtName.Value;
                            item["display"] = chkDisplay.Checked.ToString();
                            item["latitude"] = txtLat.Value;
                            item["longitude"] = txtLng.Value;
                            store.Save(item);
                        }
                    }
                }

Thanks

Jon

#113429
Nov 20, 2014 9:26
Vote:
 

You don't have to give each item in your store an ID (if you leave it blank, it will be generated for you) - but you SHOULD be consistent about whether or not you fill in the ID property for items you store.

But do you need to retrieve the item as a PropertyBag? (I'm assuming you followed the example at http://naveedahmad.co.uk/2011/11/02/episerver-dynamic-data-store/)

You could use the store.Find method to retrieve a specific CategoryItem object from your store, like this:

// retrieve CategoryItem object
CategoryItem item = store.Find("gId", hdngId.Value);

That way you have strongly typed access to CategoryItem properties. 

You should be able to edit any properties and update the record by doing store.Save(item).

If you need more examples, you can download a DDS sample project.

#113430
Nov 20, 2014 10:31
Vote:
 

Thats great - can you get the data from the DDS when using a webservice? for example:

  var store = DynamicDataStoreFactory.Instance.GetStore(typeof(CategoryItems));

            var responses = from r in store.Items<CategoryItems>()
                            select r;

I use the exact code in a page and I get the data back but calling it from a webservice I get Zero items returned.

Jon

#113448
Nov 20, 2014 18:02
Vote:
 

Hi Jon,

Try giving your DDS a name such as:-

var store - DynamicDataStoreFactory.Instance.CreateStore("MyDDS", typeof(CategoryItems));

Then you can call it back by using:-

var getstore = DynamicDataStoreFActory.Instance.GetStore("MyDDS");

This seems to work for me.

Cheers

Paul

#113462
Edited, Nov 21, 2014 10:06
Vote:
 

Hi Paul,

That is a perfect solution. Many thanks

Jon

#113463
Nov 21, 2014 10:07
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.