trying to do a simple join between a small category and product table on categoryid. Everything works until I get to the CategoryName field in the loop which obviously is not in the recordset.
Any tips would be helpful:
// open a K2 Server connection
serverName.CreateConnection();
serverName.Connection.Open(connectionString.ToString());
SmartObjectClientServer SmoServer = new SmartObjectClientServer();
try
{
SmartObject smartObject = serverName.GetSmartObject("dbo_products_K2TestInput1_on_LOCALHOST");
SmartObject smartObject2 = serverName.GetSmartObject("dbo_categories_K2TestInput2_on_LOCALHOST");
// specify which method will be called
SmartListMethod getList = smartObject.ListMethods["List"];
smartObject.MethodToExecute = getList.Name;
SmartListMethod getList2 = smartObject2.ListMethods["List"];
smartObject2.MethodToExecute = getList2.Name;
JoinDetails jd = new JoinDetails();
Join join = new Join();
join.From = smartObject;
join.From.ResultName = "PR";
join.From.MethodToExecute = "List";
join.To = smartObject2;
join.To.ResultName = "CA";
join.To.MethodToExecute = "List";
join.AddCondition(join.To.Properties[0], join.From.Properties[2]);
jd.Joins.Add(join);
jd.From = join.From;
SmartObjectList smoList = serverName.ExecuteList(jd);
//read the return properties of the SmartObject
foreach (SmartObject smo in smoList.SmartObjectsList)
{
Console.WriteLine("ProductID: " + smo.Properties["ProductID"].Value);
Console.WriteLine("CategoryID: " + smo.Properties["CategoryID"].Value);
Console.WriteLine("ProductName: " + smo.Properties["ProductName"].Value);
Console.WriteLine("CategoryName: " + smo.Properties["CategoryName"].Value);
}
Console.ReadLine();