How to find columns used in a DataColumn.Expression ?
-
6 มีนาคม 2555 22:59
Looking for a way to find out the columns used in a DataColumn.Expression
it should be possible i hope ?
- แก้ไขโดย kumarnyc 6 มีนาคม 2555 22:59
ตอบทั้งหมด
-
7 มีนาคม 2555 6:25ผู้ดูแล
Hi kumarnyc,
Welcome!
I think you can use Reflector to retrieve the column information:
foreach (var item in table.Columns) { var test= item.GetType().GetProperty("Expression").GetValue(item, null); }
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
7 มีนาคม 2555 14:44
That's the same as
foreach (var item in table.Columns) { var test= item.Expression; }
what i am looking for is
given this column def, where f1-f6 are other fields
Columns.Add("formula", typeof(double), " f1 +f2 (f3*f4) + f5 / f6 ");
a method such as DataColumn.GetFieldsUsedInExpression()
which returns f1, f2, f3, f4, f5, f6
Sorry i was not clear earlier
-
12 มีนาคม 2555 9:23
Hi,
The easy way to find the Fields is use Regular Expression here.
http://www.regular-expressions.info/dot.html
I am fish.
-
12 มีนาคม 2555 9:29I don't think there is an easy way. You should parse the formula.
Miha Markic [MVP C#] http://blog.rthand.com
-
12 มีนาคม 2555 10:14
Yea but you have typed those columns, strange question, seems if you are an end user who knows nothing about the program?
Like in a metaphor: "how can I count the toes on my left feet".
Success
Cor