Is it possible to update an existing row in the DynamicDataStore (DDS) and if so how do you do it?
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.
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,
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?
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.
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;
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.
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.
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.
That is a perfect solution. Many thanks