Re: Type convertsion from string
- From: "Andrus" <kobruleht2@xxxxxx>
- Date: Tue, 16 Oct 2007 18:22:24 +0300
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.
.
- Follow-Ups:
- Re: Type convertsion from string
- From: Marc Gravell
- Re: Type convertsion from string
- References:
- Type convertsion from string
- From: Andrus
- Re: Type convertsion from string
- From: Jon Skeet [C# MVP]
- Re: Type convertsion from string
- From: Andrus
- Re: Type convertsion from string
- From: Marc Gravell
- Re: Type convertsion from string
- From: Andrus
- Re: Type convertsion from string
- From: Marc Gravell
- Re: Type convertsion from string
- From: Andrus
- Re: Type convertsion from string
- From: Marc Gravell
- Type convertsion from string
- Prev by Date: Rounding decimals to interger
- Next by Date: regular expression - matching a string
- Previous by thread: Re: Type convertsion from string
- Next by thread: Re: Type convertsion from string
- Index(es):
Relevant Pages
|