Jobs Module / Dynamic Data
The jobs module example uses "dynamic data" and extends Document with several fields.
Hello Lorne,
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 willbe 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.
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.
Best wishes,
Ivan Dimitrov
the Telerik team
Hi Lorne,
If you use ADO.NET, Entity Framework you should create your own data persistence classes. The idea of dynamic fields it to use them instead of creating a custom data layer.
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)
All the best,
Ivan Dimitrov
the Telerik team