This commit is contained in:
@@ -230,7 +230,7 @@ namespace AyaNova.Biz
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
||||
AyaObjectType = (int)AyaType.Widget,
|
||||
SqlIdColumnName = "awidget.id",
|
||||
SqlDisplayColumnName = "awidget.name"
|
||||
SqlValueColumnName = "awidget.name"
|
||||
});
|
||||
l.Add(new AyaObjectFieldDefinition
|
||||
{
|
||||
@@ -239,13 +239,13 @@ namespace AyaNova.Biz
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
||||
AyaObjectType = (int)AyaType.User,
|
||||
SqlIdColumnName = "auser.id",
|
||||
SqlDisplayColumnName = "auser.name"
|
||||
SqlValueColumnName = "auser.name"
|
||||
});
|
||||
l.Add(new AyaObjectFieldDefinition
|
||||
{
|
||||
LtKey = "UserEmailAddress",
|
||||
FieldKey = "emailaddress",
|
||||
SqlDisplayColumnName = "auseroptions.emailaddress",
|
||||
SqlValueColumnName = "auseroptions.emailaddress",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.EmailAddress
|
||||
});
|
||||
break;
|
||||
@@ -365,7 +365,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//SERVER - for building sql queries
|
||||
public string SqlIdColumnName { get; set; }
|
||||
public string SqlDisplayColumnName { get; set; }
|
||||
public string SqlValueColumnName { get; set; }
|
||||
|
||||
|
||||
public AyaObjectFieldDefinition()
|
||||
@@ -381,15 +381,15 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//Get column to query for display name or use FieldName if there is no difference
|
||||
public string GetSqlDisplayColumnName()
|
||||
public string GetSqlValueColumnName()
|
||||
{
|
||||
if (string.IsNullOrEmpty(SqlDisplayColumnName))
|
||||
if (string.IsNullOrEmpty(SqlValueColumnName))
|
||||
{
|
||||
return FieldKey.ToLowerInvariant();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SqlDisplayColumnName;
|
||||
return SqlValueColumnName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace AyaNova.Biz
|
||||
{//Ignore missing fields in production
|
||||
|
||||
sb.Append(", ");
|
||||
sb.Append(o.GetSqlDisplayColumnName());
|
||||
sb.Append(o.GetSqlValueColumnName());
|
||||
|
||||
//does it also have an ID column?
|
||||
if (!string.IsNullOrWhiteSpace(o.SqlIdColumnName))
|
||||
|
||||
@@ -471,6 +471,7 @@ namespace AyaNova.Biz
|
||||
int returnRowCount = AyaObjectFields.Count();
|
||||
List<List<AyaFieldData>> rows = new List<List<AyaFieldData>>();
|
||||
long totalRecordCount = 0;
|
||||
|
||||
|
||||
//RUN THE QUERY
|
||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||
@@ -485,17 +486,26 @@ namespace AyaNova.Biz
|
||||
while (dr.Read())
|
||||
{
|
||||
List<AyaFieldData> row = new List<AyaFieldData>(returnRowCount);
|
||||
|
||||
//GetOrdinal is flakey in npgsql so need an alternative, probably faster this way anyway
|
||||
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
|
||||
//INSERT INTO THE RETURN ROWS LIST
|
||||
foreach (AyaObjectFieldDefinition f in AyaObjectFields)
|
||||
{
|
||||
AyaFieldData d = new AyaFieldData();
|
||||
d.v = dr.GetValue(dr.GetOrdinal(f.SqlDisplayColumnName));
|
||||
if (f.SqlIdColumnName != null)
|
||||
AyaFieldData AyaField = new AyaFieldData();
|
||||
AyaField.v = dr.GetValue(nCurrentColumnPointer);
|
||||
|
||||
nCurrentColumnPointer++;
|
||||
if (!isFirstDFColumn && f.SqlIdColumnName != null)//skip over df column id, it's not there
|
||||
{
|
||||
d.Id = dr.GetInt64(dr.GetOrdinal(f.SqlIdColumnName));
|
||||
AyaField.Id = dr.GetInt64(nCurrentColumnPointer);
|
||||
nCurrentColumnPointer++;
|
||||
}
|
||||
|
||||
isFirstDFColumn=false;
|
||||
row.Add(AyaField);
|
||||
}
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user