This commit is contained in:
2020-01-16 00:06:27 +00:00
parent a9bd85230c
commit 90fc9811a6
2 changed files with 37 additions and 21 deletions

View File

@@ -61,7 +61,10 @@ namespace AyaNova.Biz
TODO: going to need some SQL hints added here
- SqlIDColumn indicating what the ID column is to fetch the underlying value from
- SqlColumn indicating an alternative column name as known to the sql server if it varies from the propertyname (in lowercase)
Also: going to need a definition of the table name and the default identity column
Maybe decorate with an INTERNAL ONLY bool so that we see it at the server but not at the client or when fetched as possible fields
hypothetical to help develop this:
Client and head office list:
{key=ClientName, propertyname=Name, idcolumn=id,}
@@ -272,7 +275,7 @@ namespace AyaNova.Biz
sb.Append($",\"ay\":{(int)o.AyObjectType}");
sb.Append("}");
}
}
sb.Append("]");
@@ -301,6 +304,11 @@ namespace AyaNova.Biz
//then the type to open is set here
public int AyObjectType { get; set; }
//For query building
//This is the equivalent of the v7 SqlColumnNameAttribute
public string SqlIdColumn { get; set; }
public string SqlColumn { get; set; }
public ObjectField()
{
@@ -313,6 +321,31 @@ namespace AyaNova.Biz
MiniAvailable = true;
//Set openable object type to no type which is the default and means it's not a link to another object
AyObjectType = (int)AyaType.NoType;
}
public string GetSqlColumnName()
{
if (string.IsNullOrEmpty(SqlColumn))
{
return PropertyName.ToLowerInvariant();
}
else
{
return SqlColumn;
}
}
public string GetSqlIdColumnName()
{
if (string.IsNullOrEmpty(SqlIdColumn))
{
return "id";
}
else
{
return SqlIdColumn;
}
}
}

View File

@@ -40,30 +40,13 @@ namespace AyaNova.Biz
foreach (string ColumnName in templateFieldList)
{
//NOPE, NOPE, NOPE....rather than this, it needs to get the names by consulting the ObjectFields list which may contain overrides for the sql name etc
sb.Append(ColumnName);
}
//iterate the datafilter and concatenate a sql query from it
var SortArray = JArray.Parse(dataFilter.Sort);
for (int i = 0; i < SortArray.Count; i++)
{
var SortItem = SortArray[i];
var fld = SortItem["fld"].Value<string>();
var dir = SortItem["dir"].Value<string>();
sb.Append(" ");
sb.Append(fld);
sb.Append(" ");
sb.Append(dir == "+" ? "ASC" : "DESC");
if (i < SortArray.Count - 1)
{
sb.Append(",");
}
}
return " ORDER BY" + sb.ToString();
return sb.ToString();
}