DynamicObject Packet Operations

Source: Internet
Author: User

DynamicObject structure is very simple and clear, is a dictionary, similar to a dictionary<string, Object&gt, 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.