DynamicObject structure is very simple and clear, is a dictionary, similar to a dictionary<string, Object>, where the object may be a simple value (normal field), may be a complex value (such as the base data field), More likely to be a collection (such as a document body);
If the value is a collection, then the member of the collection will be a DynamicObject object.
In fact, we do not recommend that partners operate DynamicObject directly, so this is not an introduction.
We want developers to read field data in the following ways:
1.In the interface plug-in, the following methods are taken:
This . Model.getvalue (key, rowIndex);
2.In other places where model is missing, the following methods are used:
Normal fields:
var field = Businessinfo.getfield (key);
String value = field. Dynamicproperty.getvalue (dynamicobject);
Basic data fields:
var Basefield = Businessinfo.getfield (key) as Basedatafield;
Long id = convert.toint64 (baseField.RefIdDynamicProperty.GetValue (DynamicObject));
DynamicObject bdinfo = BaseField.DynamicProperty.GetValue (dynamicobject) as DynamicObject;
Document Body:
var entity = businessinfo.getentity (key);
dynamicobjectcollection rows = entity. Dynamicproperty.getvalue (DynamicObject) as dynamicobjectcollection;
Multi-Select auxiliary materials:
Mulassistantfield targetfld = Businessinfo.getfield (key) as Mulassistantfield;
dynamicobjectcollection mulassirows = TargetFld.RefEntityDynamicProperty.GetValue (headobj) as dynamicobjectcollection;
foreach (var row in mulassirows)
{
string id = convert.tostring (targetFld.RefIDDynamicProperty.GetValue (Row));
DynamicObject bdinfo = TargetFld.DynamicProperty.GetValue (row) as DynamicObject;
}
multiple selection of basic information, similar to multi-select auxiliary materials, do not repeat;
all of these methods are given by the field, the Dynamicproperty property on the entity to the DynamicObject, and this property also provides the SetValue method assignment;
3. when there is no model and no field metadata, it is based on the structure of the dynamicobject itself, taking the number of layers down (advanced):
Statement 1: Take simple values
string strvalue = Convert.ToString (Dynamicobject[key]);
Statement 2: Fetching complex values
dynamicobject bdinfo = Dynamicobject[key] as DynamicObject;
Statement 3: Fetching the collection, and the value of the field in the collection
dynamicobjectcollection mulassirows = Dynamicobject[entitykey] as dynamicobjectcollection;
foreach (var row in mulassirows)
{
string id = convert.tostring (row[key]);
dynamicobject bdinfo = Row[key] as DynamicObject;
}
DynamicObject Packet Operations