DynamicData
I've seen information about how to define new meta data for DynamicData.
I've been searching for this a while too. And have come to the conclusion that it's not ready yet.
Hi,
1. You can create a new property for a given type by using TryCreateNew - tries to create a new instance of the "MetaField" with the specified field name and type. Field will be created only if the field with such name does not exist. So this create a dynamic property for your field.
2. You can create a new type which is more complicated, because currently there is no a common facade or manager that will allow you to use your custom type directly and you have to use a custom manager and WCF RESTful service to update the data for your custom type. We are working on a common facade that will be included in one of the next internal builds and will allow you manage each content type that inherits from Content.
There is an extension method - SetValue which is used to set a value to the custom field - sets the value of a dynamic property of data item to a different value.
Here are several samples that shows how to create, update or delete a property value
1. Create a new property
App.WorkWith().DynamicData().Type(typeof(NewsItem)).Field().CreateNew("somevalue", typeof(string)).SaveChanges();
2. Update the property
var itm = App.WorkWith().NewsItems().Where(ni => ni.Title == "test").Get().SingleOrDefault();
itm.SetValue("somevalue", "val");
3. Delete the property from the type.
App.WorkWith().DynamicData().Fields().Where(dc => dc.FieldName == "test").Delete();
DynamicFieldFacade has two facade method that you can use
public DynamicFieldFacade Field(Guid dynamicFieldId)
public DynamicFieldFacade Field(MetaField dynamicField)
Kind regards,
Ivan Dimitrov
the Telerik team