Inline table and Value lists access

  • Updated

Namespaces: InRule.Repository, InRule.Repository.RuleElements,
Classes: RuleApplicationDef, TableDef
See Also:
References: InRule.Repository.dll, InRule.Common.dll

There are changes to the techniques used to access inline tables; in InRule SDK 4.5 and later these are accessed through the RuleAppDef see below:

RuleApplicationDef ruleAppDef = RuleApplicationDef.Load(@"c:\temp\test.ruleapp");

// Loop through all the data elements
foreach (var dataDef in ruleAppDef.DataElements)
{
  // try to cast the dataDef into a tableDef - if this fails
  // then we will ignore the dataDef since we will only process tables
   TableDef tableDef = dataDef as TableDef;
  if (tableDef != null)
   {
      // Check its an inline table - will not process linked tables
      if (tableDef.TableSettings.TableSourceType == TableSourceType.Inline)
       {
          // get the name
          string tableName = tableDef.Name;

          // Get the data - this adds all the cols in the table
           List<string> columnNames = new List<string>();
          foreach (var col in tableDef.TableSettings.InlineDataTable.Columns)
           {
               columnNames.Add(col.ToString());
           }

          // Iterate the rows in the table and rows to XML
          foreach (System.Data.DataRow dr in tableDef.TableSettings.InlineDataTable.Rows)
           {
              // only access the fields in the collection of names- you could
              // filter using this.
              foreach (string colName in columnNames)
               {
                  // get the data for each column name
                  string rowItemData = "";
                   rowItemData = string.Format("Name:{0} Value:{1}", colName, dr[colName].ToString());
               }
           }
       }
   }

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.