Marc,
And (ahem) took full credit I notice (except for HyperDescriptor, fair
enough)
I'm sorry, this is mistake. I add you as author of this code.
This takes me back to some conversations (with you) in October? November?
You can weite runtime-extensible objects using TypeDescriptionProvider etc
without too much heartache, but you need somewhere to put the data...
ideally inside the record object so that it gets collected (GC) with the
record.
You could do something like this with a common base class for extensible
objects, but it isn't trivial.
As understand from this discussion that TypeDescriptor can be used to extend
object to show columns in DataGridView easily.
I hoped that HyperDescriptor allows to add new properties for DataGridView
binding in the fly.
I'd like easily to visualise any SELECT command results for quick design in
scripts in customer sites like
var result = db.ExecuteQuery<object>("SELECT * FROM Customers, Orders WHERE
Order.ID=Customer.ID");
myDataGridView.DataSource = result;
and then grid automagically visualizes the result.
I guess this would be possible - but you'd have to pass this in as the
<T>, so you would have to use reflection to invoke the method. In this
case, personally I'd recommend getting the columns right, or using
something pre-rolled like DataTable.
For debugging and for quick result visualization/verification dynamic
entities whould be handy.
I'm not sure what solution to try for this:
Your extensible TypeDescriptor sample code which you posted previous year
or
MS Dynamic Linq library CreateClass() method:
1. create datareader and retrieve data
2. Create property list from DataReader data DynamicProperty[] props =
.....
3. Create dynamic type using Dynamic Linq library
Type type = DynamicExpression.CreateClass(props);
4. Create and return list of entities based on this type
Andrus.
P.S. Sorry again for credit mistake, I will fix it.
Do you want to see the result? I think you are the first person in the
world who created OpenSource ExecuteQuery<Tresult>() implementation.
Since DbLinq license is very liberal, all commerical DLinq driver writers
like Frans and open source programmers can use your implementation as
template.
So this code must show best coding style possible.