How hard is it to generate code at runtime?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a situation where I want to generate code (whether C# or IL I don't
know which is easier or whether C# is slower because needs to be converted to
IL at the end).

I have a dynamic SQL string, say:

--------------------
"Select " + cslist + "into :lsVariable, :llidValor" + " FROM " + ff + "
where variable like :psVariable";
--------------------

and want to bind the input and output variables to variables in the method,
say to parameters. And I don't want this code to be seen - it makes it less
readable and unnecesarily exposes the implementation.

In the above example, cslist would be a string variable with the list of
columns wanted in the result set (an input variable), :psVariable would
contain a value for the where clause (another input variable - this time it
needs to be parsed and bound to an existing variable in scope) - and the
:IsVariable and :llidValor who determine where the corresponding values from
the loaded record set will go.

Do you see the point in this? Can you point me (no pun intended) to where I
can find code that would generate this runtime binding code?
 
Juan said:
Hi,

I have a situation where I want to generate code (whether C# or IL I
don't know which is easier or whether C# is slower because needs to
be converted to IL at the end).

I have a dynamic SQL string, say:

--------------------
"Select " + cslist + "into :lsVariable, :llidValor" + " FROM " + ff +
" where variable like :psVariable";
--------------------

and want to bind the input and output variables to variables in the
method, say to parameters. And I don't want this code to be seen - it
makes it less readable and unnecesarily exposes the implementation.

In the above example, cslist would be a string variable with the list
of columns wanted in the result set (an input variable), :psVariable
would contain a value for the where clause (another input variable -
this time it needs to be parsed and bound to an existing variable in
scope) - and the :IsVariable and :llidValor who determine where the
corresponding values from the loaded record set will go.

Do you see the point in this? Can you point me (no pun intended) to
where I can find code that would generate this runtime binding code?

Every O/R mapper worth mentioning does what you're asking. :)

FB


--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
Back
Top