This commit is contained in:
2020-01-20 23:37:43 +00:00
parent d5a645924d
commit 5937963af0

View File

@@ -433,8 +433,7 @@ namespace AyaNova.Biz
{ {
templateFieldList = ((JArray)jtemplate["full"]).ToObject<string[]>(); templateFieldList = ((JArray)jtemplate["full"]).ToObject<string[]>();
} }
//manually add the default field
templateFieldList.Prepend("df");
//BUILD THE QUERY //BUILD THE QUERY
/* /*
@@ -488,15 +487,13 @@ namespace AyaNova.Biz
//RETURN OBJECTS //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<List<AyaFieldData>> rows = new List<List<AyaFieldData>>(); List<List<AyaFieldData>> rows = new List<List<AyaFieldData>>();
long totalRecordCount = 0; long totalRecordCount = 0;
//QUERY THE DB
//RUN THE QUERY
using (var command = ct.Database.GetDbConnection().CreateCommand()) using (var command = ct.Database.GetDbConnection().CreateCommand())
{ {
ct.Database.OpenConnection(); ct.Database.OpenConnection();
//GET DATA RETURN ROWS //GET DATA RETURN ROWS
@@ -506,18 +503,15 @@ namespace AyaNova.Biz
while (dr.Read()) while (dr.Read())
{ {
List<AyaFieldData> row = new List<AyaFieldData>(returnRowColumnCount); List<AyaFieldData> row = new List<AyaFieldData>(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 //GetOrdinal is flakey in npgsql so just going by field definition and ordinal numerically
int nCurrentColumnPointer = 0; int nCurrentColumnPointer = 1;//start at 1
//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
//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 //INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
//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
foreach (string TemplateField in templateFieldList) foreach (string TemplateField in templateFieldList)
{ {
//get the AyaObjectFieldDefinition //get the AyaObjectFieldDefinition
@@ -526,14 +520,12 @@ namespace AyaNova.Biz
AyaFieldData AyaField = new AyaFieldData(); AyaFieldData AyaField = new AyaFieldData();
AyaField.v = dr.GetValue(nCurrentColumnPointer); AyaField.v = dr.GetValue(nCurrentColumnPointer);
nCurrentColumnPointer++; if (f.SqlIdColumnName != null)//skip over df column id, it's not there
if (!isFirstDFColumn && f.SqlIdColumnName != null)//skip over df column id, it's not there
{ {
AyaField.i = dr.GetInt64(nCurrentColumnPointer); AyaField.i = dr.GetInt64(nCurrentColumnPointer);
nCurrentColumnPointer++; nCurrentColumnPointer++;
} }
isFirstDFColumn = false;
row.Add(AyaField); row.Add(AyaField);
} }
rows.Add(row); rows.Add(row);