While looking into this, I recognized we needed DataProjectorToValueList<T> class, and that's already there, which means I can rewrite your failing query as:
var qf = new QueryFactory();
var query2 = qf.Create()
.Select(CategoryFields.CategoryName)
.OrderBy(CategoryFields.CategoryName.Ascending());
var queryList2 = new List<string>();
using (var dataAdapter = new DataAccessAdapter())
{
dataAdapter.FetchAsProjection(query2, new DataProjectorToValueList<string>(queryList2);
}
Console.WriteLine($"\nDynamic query Product Categories; Row count: {queryList2.Count}");
foreach (var s in queryList2)
{
Console.WriteLine(s);
}
In case of a stored proc, that's a different story, for stored proc results, you need a full projection which is a bit cumbersome for a single field:
var query3 = RetrievalProcedures.GetCategoryListCallAsQuery();
List<string> procList;
using (var dataAdapter = new DataAccessAdapter())
{
var qf = new QueryFactory();
var q = qf.Create().Select(()=>CategoryFields.Name.ToValue<string>());
procList = dataAdapter.FetchQueryFromSource(q, query3);
}
Console.WriteLine($"\nStored Proc Product Categories; Row count: {procList.Count}\n");
foreach (var s in procList)
{
Console.WriteLine(s);
}
It's not doable to handle both situations with a single method, as the first requires a query to be specified and the second requires an IRetrievalQuery object which is generated from the queryspec query in the first situation.
The first query, with queryspec, is IMHO doable with the current API and that setup and doesn't require a different method. The stored proc is a problematic one, and it fails at the same spot as a PlainSQL value list query.
For the stored proc & plain sql situation, we'll look into how to solve that as it should be possible to do that without a lot of trouble. As both use the same projection system internally, fixing one will fix the other as well.