This commit is contained in:
@@ -44,7 +44,7 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
//BUILD THE QUERY
|
//BUILD THE QUERY
|
||||||
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
||||||
var qSelectColumns = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, ListViewFieldList);
|
var SelectBuild = DataListSqlSelectBuilder.Build(DataList.FieldDefinitions, ListViewFieldList);
|
||||||
|
|
||||||
//FROM CLAUSE
|
//FROM CLAUSE
|
||||||
var qFrom = DataList.SQLFrom;
|
var qFrom = DataList.SQLFrom;
|
||||||
@@ -68,7 +68,7 @@ namespace AyaNova.DataList
|
|||||||
string qDataQuery = string.Empty;
|
string qDataQuery = string.Empty;
|
||||||
string qTotalRecordsQuery = string.Empty;
|
string qTotalRecordsQuery = string.Empty;
|
||||||
|
|
||||||
qDataQuery = $"{qSelectColumns} {qFrom} {qWhere} {qOrderBy} {qLimitOffset}".Replace(" ", " ");
|
qDataQuery = $"{SelectBuild.Select} {qFrom} {qWhere} {qOrderBy} {qLimitOffset}".Replace(" ", " ");
|
||||||
qTotalRecordsQuery = $"SELECT COUNT(*) {qFrom} {qWhere}".Replace(" ", " ");
|
qTotalRecordsQuery = $"SELECT COUNT(*) {qFrom} {qWhere}".Replace(" ", " ");
|
||||||
|
|
||||||
//RETURN OBJECTS
|
//RETURN OBJECTS
|
||||||
@@ -103,10 +103,10 @@ namespace AyaNova.DataList
|
|||||||
}
|
}
|
||||||
|
|
||||||
//GetOrdinal by name is flakey in npgsql so just going by field definition and ordinal numerically
|
//GetOrdinal by name is flakey in npgsql so just going by field definition and ordinal numerically
|
||||||
int nCurrentColumnPointer = 1;//start at 1
|
// int nCurrentColumnPointer = 1;//start at 1
|
||||||
// dr.GetOrdinal();
|
// dr.GetOrdinal();
|
||||||
// dr.GetName();
|
// dr.GetName();
|
||||||
//INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
|
//INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
|
||||||
foreach (string TemplateField in ListViewFieldList)
|
foreach (string TemplateField in ListViewFieldList)
|
||||||
{
|
{
|
||||||
if (TemplateField == "df")
|
if (TemplateField == "df")
|
||||||
@@ -115,7 +115,18 @@ namespace AyaNova.DataList
|
|||||||
AyaDataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(x => x.FieldKey == TemplateField);
|
AyaDataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(x => x.FieldKey == TemplateField);
|
||||||
if (f.IsCustomField)
|
if (f.IsCustomField)
|
||||||
{
|
{
|
||||||
var v=dr;
|
|
||||||
|
AyaFieldData AyaField = new AyaFieldData();
|
||||||
|
var cust = dr.GetString(SelectBuild.map[f.GetSqlValueColumnName()]);
|
||||||
|
if (!string.IsNullOrWhiteSpace(cust))
|
||||||
|
{
|
||||||
|
JObject j = JObject.Parse(cust);
|
||||||
|
//convert field name to cust name then get value
|
||||||
|
var InternalCustomFieldName = AyaFormFieldDefinitions.TranslateLTCustomFieldToInternalCustomFieldName(TemplateField);
|
||||||
|
AyaField.v = j[InternalCustomFieldName].Value<object>();
|
||||||
|
row.Add(AyaField);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO: Custom field handling
|
TODO: Custom field handling
|
||||||
GetName works just not with multipart identifiers
|
GetName works just not with multipart identifiers
|
||||||
@@ -123,7 +134,7 @@ namespace AyaNova.DataList
|
|||||||
I could map the ordinal when generating the Select fields so that I have a map to refer to here
|
I could map the ordinal when generating the Select fields so that I have a map to refer to here
|
||||||
mapping in advance actually makes a lot of sense, then no more of this fragility of going by pointer index and hoping for the best
|
mapping in advance actually makes a lot of sense, then no more of this fragility of going by pointer index and hoping for the best
|
||||||
it would just be premapped out.
|
it would just be premapped out.
|
||||||
|
|
||||||
dr.GetOrdinal(f.SqlValueColumnName)
|
dr.GetOrdinal(f.SqlValueColumnName)
|
||||||
'dr.GetOrdinal(f.SqlValueColumnName)' threw an exception of type 'System.IndexOutOfRangeException'
|
'dr.GetOrdinal(f.SqlValueColumnName)' threw an exception of type 'System.IndexOutOfRangeException'
|
||||||
f.SqlValueColumnName
|
f.SqlValueColumnName
|
||||||
@@ -138,15 +149,16 @@ dr.GetOrdinal("customfields");
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
AyaFieldData AyaField = new AyaFieldData();
|
AyaFieldData AyaField = new AyaFieldData();
|
||||||
AyaField.v = dr.GetValue(nCurrentColumnPointer);
|
AyaField.v = dr.GetValue(SelectBuild.map[f.GetSqlValueColumnName()]);
|
||||||
nCurrentColumnPointer++;
|
//nCurrentColumnPointer++;
|
||||||
|
|
||||||
if (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
|
||||||
{
|
{
|
||||||
if (!await dr.IsDBNullAsync(nCurrentColumnPointer))
|
var ordinal = SelectBuild.map[f.SqlIdColumnName];
|
||||||
AyaField.i = dr.GetInt64(nCurrentColumnPointer);
|
if (!await dr.IsDBNullAsync(ordinal))
|
||||||
|
AyaField.i = dr.GetInt64(ordinal);
|
||||||
|
|
||||||
nCurrentColumnPointer++;
|
//nCurrentColumnPointer++;
|
||||||
}
|
}
|
||||||
row.Add(AyaField);
|
row.Add(AyaField);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,16 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace AyaNova.DataList
|
namespace AyaNova.DataList
|
||||||
{
|
{
|
||||||
|
internal class SqlSelectBuilderResult
|
||||||
|
{
|
||||||
|
internal Dictionary<string, int> map { get; set; }
|
||||||
|
internal string Select { get; set; }
|
||||||
|
}
|
||||||
internal static class DataListSqlSelectBuilder
|
internal static class DataListSqlSelectBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
//Build the SELECT portion of a list query based on the ListView fields
|
//Build the SELECT portion of a list query based on the ListView fields
|
||||||
internal static string Build(List<AyaDataListFieldDefinition> objectFieldsList, List<string> listViewFieldList)
|
internal static SqlSelectBuilderResult Build(List<AyaDataListFieldDefinition> objectFieldsList, List<string> listViewFieldList)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -97,8 +102,9 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TODO: return map and sb as composite object here
|
return new SqlSelectBuilderResult() { map = map, Select = sb.ToString() };
|
||||||
return sb.ToString();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user