Jobs Module / Dynamic Data

Posted by Community Admin on 03-Aug-2018 19:42

Jobs Module / Dynamic Data

All Replies

Posted by Community Admin on 03-Dec-2010 00:00

The jobs module example uses "dynamic data" and extends Document with several fields.


If I were building a real jobs module, I would very likely create a new data type for this, rather than appending new fields onto Document.

Am I misunderstanding the Sitefinity concept of Dynamic Data? Am I incorrect in assuming I can, in effect, create a custom data type with fields that I define?

I've seen some examples of creating my own custom type and my own custom fields for that type. However, I cannot seem to find any definitive answers as to whether or not I can create new entries in the table for my custom type, how I can query the table for records, or how I can update or delete them.

Now, back to what I mentioned earlier about creating a real jobs module. If I were to do that, can I use dynamic data, or should I be using some other means to access data in the database (ADO, Entity Framework, NHibernate, etc.)?


Posted by Community Admin on 06-Dec-2010 00:00

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

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Dec-2010 00:00

How do you recommend dealing with custom data? Should one use the limited dynamic data facilities that you provide, or is it better to use other meas of data access, such as ADO.NET, Entity Framework, etc.?

Also, do you have a complete example of using custom types, including creating, deleting, updating, etc.?

Thanks.

Posted by Community Admin on 06-Dec-2010 00:00

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

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed