Re: Type convertsion from string



Marc,

I want to allow users to add calculated columns to table at runtime.
Yes it is. But you need to know a range of things from
System.ComponentModel. If this is a requirement, can I suggest DataTable?
It isn't ideal from many OO standpoints, but it supports this
out-of-the-box.

thank you very much.
I need to use static methods (from string, Math and other classes) in
expressions.
I havent found any way to use them from DataTable column Expression
property.
How to call static methods from ADO.NET expressions ?

For dynamic property additions (this is *not* trivial), see:
http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/f4d8bb5dcdb82a9f/
However, this doesn't even begin to discuss how you would parse the
expression, i.e. "Age * 2"... so again, I say: look at DataTable... or
Excel. This is not an easy area.

I'm thinking about the following:

1. Expression are stored in SQL server table.
2. Before first access to every entity object application creates entity
class (.cs file) from table structure in database and adds expressions as
properties to this file.
3. Application compiles cs file and loads this file to memory.

This avoids writing custom TypeDescriptor and Expression parser and allows
to use full power of C# to write expressions.

Is this best solution ?

Or is it better to create custom type "ExpressionMethod" and custom type
converter which converts string to ExpressionMethod type (to assembly or to
IL code)?

Andrus.


.



Relevant Pages

  • Re: Regular Expression, to use or not to use...
    ... So I have something that will search the string 10x ... Yea thats true, like I said I still use them occasionally, as a hack, ... Also this is an extremly simple re, no |'s or complex expressions. ... >> simple string operations where I can come up with the expression in a ...
    (microsoft.public.dotnet.general)
  • Re: Small confusion about negative lookbehind
    ... > My candidate string is "ab". ... > The expressions I'm testing this string against are the following, ... but the position between characters. ... Regular expressions describe not only strings, ...
    (comp.lang.java.programmer)
  • Re: Why not FP for Money?
    ... >> conversion of binary floats to decimal floats, and the string looks ... >> out of place in numeric expressions. ... > that using 'd' is a compromise to having no way to write ... Carlos Ribeiro ...
    (comp.lang.python)
  • Re: Regular Expression, to use or not to use...
    ... > Expressions for a long time now, ... > external tools to help me with. ... > order of 10 times slower then straight forward string parsing code. ... This could be a result of .NET engine, ...
    (microsoft.public.dotnet.general)
  • RE: speed up string matching
    ... > I need to match an expression and its reverse to a very long string. ... you'd have to merge your expressions somehow - the easiest ... So in order to match a very long string with multiple expressions simultaneously and faster than the matching procedure I have described above I need multiple computers? ...
    (perl.beginners)