From 5937963af0807b06f610774006bf1a81ffa6f236 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 20 Jan 2020 23:37:43 +0000 Subject: [PATCH] --- server/AyaNova/biz/WidgetBiz.cs | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index e4f23cc4..bbaaf862 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -433,8 +433,7 @@ namespace AyaNova.Biz { templateFieldList = ((JArray)jtemplate["full"]).ToObject(); } - //manually add the default field - templateFieldList.Prepend("df"); + //BUILD THE QUERY /* @@ -488,15 +487,13 @@ namespace AyaNova.Biz //RETURN OBJECTS - int returnRowColumnCount = templateFieldList.Count();//AyaObjectFields.Count(); + int returnRowColumnCount = templateFieldList.Count() + 1;//Templates don't have the DF column in them but we need it and it's in the query so plus one List> rows = new List>(); long totalRecordCount = 0; - - //RUN THE QUERY + //QUERY THE DB using (var command = ct.Database.GetDbConnection().CreateCommand()) { - ct.Database.OpenConnection(); //GET DATA RETURN ROWS @@ -506,18 +503,15 @@ namespace AyaNova.Biz while (dr.Read()) { List row = new List(returnRowColumnCount); + + //PROCESS THE DF DEFAULT FIRST COLUMN + //first column is always the underlying id value of the default record to open for this row in the client ui + row.Add(new AyaFieldData() { v = dr.GetInt64(0) }); + //GetOrdinal is flakey in npgsql so just going by field definition and ordinal numerically - int nCurrentColumnPointer = 0; - //flag to handle first column which has no display value, just an id instead - bool isFirstDFColumn = true; - //Iterate object fields, build return row list as required + int nCurrentColumnPointer = 1;//start at 1 - //WAIT A SECOND, this is not correct, we are meant to return the template fields only, not all the fields in the objectfieldefinition which is a superset of the template - //instead it needs to iterate the *template* (but do the DF field first on it's own) and only grab the data that's in the template - //TEST THIS BY ADDING SUPERFLOUS FIELD TO THE OBJECTFIELDEFINITION THAT ISN'T IN THE TEMPLATE - //See the select builder, IIRC it already does select only the fields required, it's probably just this block of code below that needs adapting - - //INSERT INTO THE RETURN ROWS LIST + //INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST foreach (string TemplateField in templateFieldList) { //get the AyaObjectFieldDefinition @@ -526,14 +520,12 @@ namespace AyaNova.Biz AyaFieldData AyaField = new AyaFieldData(); AyaField.v = dr.GetValue(nCurrentColumnPointer); - nCurrentColumnPointer++; - if (!isFirstDFColumn && f.SqlIdColumnName != null)//skip over df column id, it's not there + if (f.SqlIdColumnName != null)//skip over df column id, it's not there { AyaField.i = dr.GetInt64(nCurrentColumnPointer); nCurrentColumnPointer++; } - isFirstDFColumn = false; row.Add(AyaField); } rows.Add(row);