Note When you click Test Policy in the Business Rules Composer to test the policy, the condition is evaluated or the action is fired successfully.
Note If you build the rules by using database objects where “database binding type”= “Data table/data row”, the composer executes a SELECT * FROM TABLE command and asserts the resulting rows as a TypedDataTable class when the policy is tested. In the following instructions, you must create a TypedDataTable in the same way and use it instead of a DataConnection object, instead of creating a DataConnection object. For more information, see the BizTalk Business Rules documentation.
Create a DataConnection objectCreate a DataConnection object in the orchestration, and pass the DataConnection object into the Call Rules shape with the document and any other objects that you pass in. If the policy changes the database data, you must commit the transaction after the policy executes. For an example of how to do this, see the sample code in the "More Information" section.
Add a FactRetriever objectAdd a FactRetriever object to the policy. This object is called when a policy is fetched and can be used to create and to assert the DataConnection object. In BizTalk Server 2006, a second interface called IFactRemover can be defined on the same object and is called when the policy is disposed. Therefore, you can commit the database changes when the policy has finished executing. The advantage of using the second resolution is that the FactRetriever object is set up when the policy is created. Orchestrations that use the policy do not have to be aware that a database is used. The drawback is that the database must be known when the policy is created, and you cannot use a different database at execution time.
- Create the following variables.Note DataCon, SqlCon, and SqlTran are examples of variable names. You may use different names.
DataCon of type Microsoft.RuleEngine.DataConnection
SqlCon of type System.Data.SqlClient.SqlConnection
SqlTran of type System.Data.SqlClient.SqlTransaction
- In an Expression shape before the Call Rules shape, add code that is similar to the following.
SqlCon.ConnectionString = "Data Source=(local);Initial Catalog=Test;Integrated Security=SSPI";
SqlTran = SqlCon.BeginTransaction();
DataCon = new Microsoft.RuleEngine.DataConnection("test", "FlagTable", SqlCon, SqlTran);
- In an Expression shape after the Call Rules shape, add the following code.
Article ID: 897292 - Last Review: 10 Sep 2008 - Revision: 1