I ended up just creating my own functions and they seem to work so far. It was a good learning experience anyway. This is my version of the Data Column Lookup List. I think the method used in app studio always returns the first column so “colReturnName” in not supplied in the screen shots below. Not sure if there is a more efficient way to get the value from the “Dbcontext.PcLookupTblValues…” query in the foreach loop. It seems like I could have gotten that data from the first “Dbcontext.PcLookupTblValues…” query and stored that in a variable for use inside the foreach loop. In this post @timshuwy comments below about doing a join, but not sure that applies for this example.
Note that becuase the lookup table is not a traditional table, you must join each separate column.
try {
var Dbcontext = Ice.Services.ContextFactory.CreateContext <ErpContext> ();
IEnumerable<int> rows;
if(String.IsNullOrEmpty(searchValue)){
rows = Dbcontext.PcLookupTblValues.Where(tv => tv.LookupTblID == tableId && tv.ColName == colName).ToList().Select(tv => tv.RowNum);
} else{
rows = Dbcontext.PcLookupTblValues.Where(tv => tv.LookupTblID == tableId && tv.ColName == colName && tv.DataValue == searchValue).ToList().Select(tv => tv.RowNum);
}
List <string> results = new List <string>();
foreach(var row in rows) {
var res = Dbcontext.PcLookupTblValues.FirstOrDefault(tv => tv.LookupTblID == tableId && tv.ColName == colReturnName && tv.RowNum == row);
if (res != null) {
results.Add(res.DataValueString);
}
}
output = results.Count > 1 ? string.Join("~", results) : results.FirstOrDefault();
} catch (Exception ex) {
error = ex.Message;
}