This commit is contained in:
@@ -134,35 +134,80 @@ namespace AyaNova.DataList
|
|||||||
#endif
|
#endif
|
||||||
if (o != null && o.IsRowId)//only return the rowid column
|
if (o != null && o.IsRowId)//only return the rowid column
|
||||||
{//Ignore missing fields in production
|
{//Ignore missing fields in production
|
||||||
|
AddTheColumn(sb, map, ref nOrdinal, ref firstColumnAdded, o);
|
||||||
var valueColumnName = o.GetSqlValueColumnName();
|
|
||||||
if (!map.ContainsKey(valueColumnName))
|
|
||||||
{
|
|
||||||
if (firstColumnAdded)
|
|
||||||
sb.Append(", ");
|
|
||||||
sb.Append(valueColumnName);
|
|
||||||
firstColumnAdded = true;
|
|
||||||
map.Add(valueColumnName, nOrdinal++);
|
|
||||||
}
|
|
||||||
|
|
||||||
//does it also have an ID column?
|
|
||||||
var idColumnName = o.SqlIdColumnName;
|
|
||||||
if (!string.IsNullOrWhiteSpace(idColumnName))
|
|
||||||
{
|
|
||||||
if (!map.ContainsKey(idColumnName))
|
|
||||||
{
|
|
||||||
if (firstColumnAdded)
|
|
||||||
sb.Append(", ");
|
|
||||||
sb.Append(idColumnName);
|
|
||||||
firstColumnAdded = true;
|
|
||||||
map.Add(idColumnName, nOrdinal++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//insert rowid if it wasn't specified already in the list view
|
||||||
|
//this is legit as some datalists don't have a rowid visible to user e.g. PartInventoryOnHand
|
||||||
|
if (map.Count == 0)
|
||||||
|
{
|
||||||
|
//find the rowid in the objectfields list and insert it since it wasn't in the view already
|
||||||
|
var o = objectFieldsList.FirstOrDefault(z => z.IsRowId == true);
|
||||||
|
if (o != null)
|
||||||
|
{
|
||||||
|
// if(!string.IsNullOrWhiteSpace(rowIdColumn.SqlIdColumnName)){
|
||||||
|
// map.Add(rowIdColumn.SqlIdColumnName, nOrdinal++);
|
||||||
|
// }else{
|
||||||
|
// map.Add(rowIdColumn.GetSqlValueColumnName(), nOrdinal++);
|
||||||
|
// }
|
||||||
|
AddTheColumn(sb, map, ref nOrdinal, ref firstColumnAdded, o);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return new SqlSelectBuilderResult() { map = map, Select = sb.ToString() };
|
return new SqlSelectBuilderResult() { map = map, Select = sb.ToString() };
|
||||||
}//eof
|
}//eof
|
||||||
|
|
||||||
|
private static void AddTheColumn(StringBuilder sb, Dictionary<string, int> map, ref int nOrdinal, ref bool firstColumnAdded, AyaDataListFieldDefinition o)
|
||||||
|
{
|
||||||
|
// var valueColumnName = o.GetSqlValueColumnName();
|
||||||
|
// if (!map.ContainsKey(valueColumnName))
|
||||||
|
// {
|
||||||
|
// if (firstColumnAdded)
|
||||||
|
// sb.Append(", ");
|
||||||
|
// sb.Append(valueColumnName);
|
||||||
|
// firstColumnAdded = true;
|
||||||
|
// map.Add(valueColumnName, nOrdinal++);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //does it also have an ID column?
|
||||||
|
// var idColumnName = o.SqlIdColumnName;
|
||||||
|
// if (!string.IsNullOrWhiteSpace(idColumnName))
|
||||||
|
// {
|
||||||
|
// if (!map.ContainsKey(idColumnName))
|
||||||
|
// {
|
||||||
|
// if (firstColumnAdded)
|
||||||
|
// sb.Append(", ");
|
||||||
|
// sb.Append(idColumnName);
|
||||||
|
// firstColumnAdded = true;
|
||||||
|
// map.Add(idColumnName, nOrdinal++);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var valueColumnName = o.GetSqlValueColumnName();
|
||||||
|
// if (!map.ContainsKey(valueColumnName))
|
||||||
|
// {
|
||||||
|
// if (firstColumnAdded)
|
||||||
|
// sb.Append(", ");
|
||||||
|
// sb.Append(valueColumnName);
|
||||||
|
// firstColumnAdded = true;
|
||||||
|
// map.Add(valueColumnName, nOrdinal++);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//does it also have an ID column?
|
||||||
|
var idColumnName = o.SqlIdColumnName;
|
||||||
|
if (!string.IsNullOrWhiteSpace(idColumnName))
|
||||||
|
{
|
||||||
|
// if (!map.ContainsKey(idColumnName))
|
||||||
|
// {
|
||||||
|
// if (firstColumnAdded)
|
||||||
|
// sb.Append(", ");
|
||||||
|
sb.Append(idColumnName);
|
||||||
|
// firstColumnAdded = true;
|
||||||
|
map.Add(idColumnName, 0);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
}//eoc
|
}//eoc
|
||||||
}//ens
|
}//ens
|
||||||
|
|||||||
Reference in New Issue
Block a user