I'm using LINQ to Entities to generate typed result sets in VB.Net. I've got a generic Report class as follows:
Public Class Report
Public Property Name As String
Public Property SQL As String
Public Property Type As String
End Class
Then in the calling scope I want to have code that does something like:
' create my data context
Dim context As New MyAppEntities
' get a report object out of a dropdown list
Dim rpt as Report = CType(aComboBox.SelectedItem, Report)
' create a result object based on the type stored in the object
Dim res As ObjectResult(Of rpt.Type) = context.ExecuteStoreQuery(Of rpt.Type)(rpt.SQL)
So far I'm finding that .Net won't let me set the type in the (Of Type) clause on the fly at runtime.
Does anyone know how to do this?
I've tried changing the Type property of the Report class to an object of type Type, but that doesn't work either.
BTW, I know there are alternative ways to accomplish the same thing, but I'm working with external constraints that make this what I've got to work with right now. And anyway, intuitively something like this should work and I'd like to figure out how.