Prerequisites: A valid RuleSession
Namespaces: InRule.Runtime
Classes: Entity, RuleSession
See Also: Retrieving a Rule Application, Creating a RuleSession
For typical entity models, there is a top level entity that provides access to all fields, sub-entities, and collections defined in the rule application. The alternative independent entity model approach requires the use of Independent Rulesets.
Create blank Entity
//create a blank mortgage entity
Entity mortgageEntity = ruleSession.CreateEntity("Mortgage");
Create Entities with XML
// Create a mortgage entity with XML
Entity mortgageEntity = ruleSession.CreateEntity("Mortgage",@"<Mortgage>
<LoanInfo><PropertyId>1</PropertyId><Principal>500000</Principal>
<APR>6.875</APR><TermInYears>30</TermInYears></LoanInfo><PaymentSummary/></Mortgage>");
Create the Entity model from a business object model
// Create a mortgage business object
Mortgage mortgage = new Mortgage();
LoanInfo loanInfo = new LoanInfo();
loanInfo.APR = 6.875m;
loanInfo.PropertyId = 1;
loanInfo.Principal = 500000;
loanInfo.TermInYears = 30;
mortgage.LoanInfo = loanInfo;
mortgage.PaymentSummary = new PaymentSummary();
Entity mortgageEntity = ruleSession.CreateEntity("Mortgage", mortgage);
Note: See also: Setting Fields examples
Note: In order to use object-based state, the rule application must first be bound to a .NET assembly schema. See Binding to a .NET Assembly Schema in the main InRule Help file.
Comments
0 comments
Please sign in to leave a comment.