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