I have a complicated problem involving dynamic data that
needs to be read at design time.
Here's the situation:
I have a database table called Categories (fields:
categoryID, description). At design time, I want to be
able to select all records from another table where
categories.description = 'Animal'. However, using the
description in the code is really lame and using the
categoryID is not possible because it's not known at
design time.
The idea that I have is to somehow read the data and
compile it into an enumeration class at design time.
The problem:
Compiling the data means that we get a static snap-shot of
it. This is not practical because if the data change, we
need to manually recompile it and I don't know how to do
it easily at runtime. Even if I do, I still don't know
how to recompile it automatically at design time.
My friend has an idea of using a trigger on the table to
create an MSIL of the class when the data changes. My
problem with that is that we have to hard code the
webserver path in the trigger. We can't do this with
clustering/failover.
Anyone with suggestions? Thank you so much for even
thinking about it.
Sincerely,
Enrico
Peter Koen - 09 Oct 2003 22:07 GMT
> Anyone with suggestions? Thank you so much for even
> thinking about it.
>
> Sincerely,
>
> Enrico
What about using either CodeDOM or Reflection.Emit to create the
Assembly/Classes/Enums at runtime.
like this:
1) Fetch data from database
2) take a template and insert with CodeDOM all necessary objects
3) compile to a file or bytearray
4) do a dynamic load with Assembly.Load(....)
or this:
once: build a template class
1) Fetch data from database
2) use System.Reflection.Emit to add additional fields, properties and
methods into your template class

Signature
best regards
Peter Koen
-----------------------------------
MCAD, CAI/R, CAI/S, CASE/RS, CAT/RS
http://www.kema.at