I have an object called Result<T> that has a constructor which accepts an argument of IEnumerable<T>. I’d like to be able to pass in a datatable if possible.
I tried datatable.AsEnumerable(), but where I bind to the data it was complaining that ‘MyProperty’ is not a field or property on type ‘DataRow’ – which makes sense since ‘MyProperty’ isn’t a property on ‘DataRow’, but it was a column in my datatable.
Is there a way to convert a datatable to something that I can pass into the Result object and still have it bind to, say, a gridview?
I ended up using Linq to convert the datatable into an array of anonymous objects.
Then I created a generic function to use type inference to get the anonymous object array into the Result object’s constructor
Called using
Dim result = GetResult(objs)