This commit is contained in:
2020-01-20 19:06:09 +00:00
parent 8d9fc80e68
commit c89a7bf681
4 changed files with 14 additions and 13 deletions

View File

@@ -9,7 +9,7 @@ namespace AyaNova.Biz
public class AyaFieldData
{
public object v { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] //https://www.newtonsoft.com/json/help/html/JsonPropertyPropertyLevelSetting.htm
public long? Id { get; set; }
}
}

View File

@@ -221,7 +221,7 @@ namespace AyaNova.Biz
#endregion
case TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY:
#region TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY
l.Add(new AyaObjectFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
l.Add(new AyaObjectFieldDefinition
{
@@ -281,12 +281,12 @@ namespace AyaNova.Biz
//Accept a json template
//return a column list suitable for api list return
public static string GenerateListColumnsJSONFromTemplate(AyaType defaultLinkType, List<AyaObjectFieldDefinition> objectFields, string template)
public static string GenerateListColumnsJSONFromTemplate(AyaType defaultLinkType, List<AyaObjectFieldDefinition> objectFields, string template)
{
//parse the template
var jtemplate = JObject.Parse(template);
//convert to strings (https://stackoverflow.com/a/33836599/8939)
var fullFields = ((JArray)jtemplate["full"]).ToObject<string[]>();
@@ -304,7 +304,7 @@ namespace AyaNova.Biz
//Developers little helper
if (o == null)
{
throw new System.ArgumentNullException($"DEV ERROR in objectFields::GenerateListColumnsJSONFromTemplate - field {s} specified in template was NOT found in ObjectFields list for key \"{ObjectKey}\"");
throw new System.ArgumentNullException($"DEV ERROR in objectFields::GenerateListColumnsJSONFromTemplate - field {s} specified in template was NOT found in ObjectFields list");
}
#endif

View File

@@ -13,13 +13,13 @@ namespace AyaNova.Biz
{
//Build the SELECT portion of a list query based on the template, mini or full and the object key in question
public static string Build( List<AyaObjectFieldDefinition> objectFieldsList, string template, bool mini)
public static string Build(List<AyaObjectFieldDefinition> objectFieldsList, string template, bool mini)
{
//parse the template
var jtemplate = JObject.Parse(template);
//convert to strings array (https://stackoverflow.com/a/33836599/8939)
string[] templateFieldList;
if (mini)
@@ -38,7 +38,7 @@ namespace AyaNova.Biz
AyaObjectFieldDefinition def = objectFieldsList.FirstOrDefault(x => x.FieldKey == "df");
if (def == null)
{
throw new System.ArgumentNullException($"SqlSelectBuilder: objectFieldList for key \"{objectKey}\" is missing the df default field");
throw new System.ArgumentNullException("SqlSelectBuilder: objectFieldList is missing the df default field");
}
if (string.IsNullOrEmpty(def.SqlIdColumnName))
{
@@ -58,7 +58,7 @@ namespace AyaNova.Biz
//Developers little helper
if (o == null)
{
throw new System.ArgumentNullException($"DEV ERROR in SqlSelectBuilder.cs: field {ColumnName} specified in template was NOT found in ObjectFields list for key \"{objectKey}\"");
throw new System.ArgumentNullException($"DEV ERROR in SqlSelectBuilder.cs: field {ColumnName} specified in template was NOT found in ObjectFields list");
}
#endif
if (o != null)

View File

@@ -467,8 +467,7 @@ namespace AyaNova.Biz
}
//RETURN OBJECTS
//get the return row object count (number of items in each return row)
//RETURN OBJECTS
int returnRowCount = AyaObjectFields.Count();
List<List<AyaFieldData>> rows = new List<List<AyaFieldData>>();
long totalRecordCount = 0;
@@ -478,6 +477,8 @@ namespace AyaNova.Biz
{
ct.Database.OpenConnection();
//GET DATA RETURN ROWS
command.CommandText = qDataQuery;
using (var dr = command.ExecuteReader())
{
@@ -496,11 +497,11 @@ namespace AyaNova.Biz
d.Id = dr.GetInt64(dr.GetOrdinal(f.SqlIdColumnName));
}
}
rows.Add(row);
}
}
//GET TOTAL RECORD COUNT
command.CommandText = qTotalRecordsQuery;
using (var dr = command.ExecuteReader())
{
@@ -514,7 +515,7 @@ namespace AyaNova.Biz
//TODO: Build the return object in a clean format
//I could just use a actual object class to return (object v {get;set;})
//with a optional ID that is set to json not serialize if null?
//https://www.newtonsoft.com/json/help/html/JsonPropertyPropertyLevelSetting.htm