Prerequisites: A valid Entity
Namespaces: InRule.Runtime
Classes: Field, Collection, Entity
See Also: Retrieving a Rule Application, Creating a RuleSession, Creating Entities
Retrieving a field from the entity
// Retrieve the CustomerID field from the Invoice entity.
Field customerId = invoiceEntity.Fields["CustomerID"];
Retrieving a field from a collection
// Retrieve the ProductID of the first LineItem in the LineItems collection.
Field productId = invoiceEntity.Collections["LineItems"][0].Fields["ProductID"];
Note: Collection indexing is 0-based through the SDK and 1-based for referencing from within a rule application.
Retrieving a field to set a typed variable
// Retrieve the CustomerID field value from the Invoice entity.
int customerId = invoiceEntity.Fields["CustomerID"].Value.ToInt32();
Retrieving all fields in an Entity
// Show all the fields in the Entity
foreach (Field field in invoiceEntity.Fields)
{
Console.WriteLine(string.Format("Found {0} {1}", field.Name, field.Value.ToString()));
}
Comments
0 comments
Please sign in to leave a comment.