I have a dynamic Linq query like this. I need to convert the result set into an array. But I am not able to convert the IQueryable type to an Array. Any suggestion?
my code:-
var query = Data.AsEnumerable()
.AsQueryable()
.Select("new(it[\"Country\"] as Country)", "it")
.Take(10);
foreach (string str in query) // **getting error Unable to cast object of type 'DynamicClass1' to type 'System.String**
{
}
I fixed it using like this :- foreach(var str in query) .
But I have another issue now. I have added where condition to the query. Now i am getting error "No property or field 'Country' exists in type 'DataRow'". following is my query
var query= Data.AsEnumerable().AsQueryable().Where("Country = @0", "London").Select("new (Country as Country)");
string str
is for. – GabeAsEnumerable().AsQueryable()
seems to be so bad idea... – MarcinJuraszek