Reputation: 1
I have the following static class to build an dynamic object Array:
public class oDataArray
{
public static List<List<object>> GetDataObject(DbCommand command)
{
List<List<object>> oDataList = new List<List<object>>();
using (DbDataReader dr = command.ExecuteReader())
{
if (dr.HasRows)
{
while (dr.Read())
{
List<object> oData = new List<object>();
for (int i = 0; i < dr.FieldCount; i++)
{
oData.Add(dr[i]);
}
oDataList.Add(oData);
}
}
dr.Close();
}
return oDataList;
}
}
I tried to convert it to a 2 dimensional object array via:
object[,] myNewObjectArray = oDataArray.GetDataObject(anyDbCommand).ToArray<object>().ToArray<object>();
But it will not work!? :( What I'm doing wrong?
Upvotes: 0
Views: 106
Reputation: 71
How about,
oDataArray.GetDataObject(anyDbCommand).Select(a => a.ToArray()).ToArray();
Some explanation:
Upvotes: 1