1
votes

I would like to use a little more advanced expressions i Windows Workflow Foundation (WF) workflows but I cannot find any reference to what kind of expressions that actually are accepted. Some kind of Visual Basic syntax is used, but what kind? Where is the online reference documentation?

What I would like to do is to read files, split strings, create and call .NET objects etc.

Thank you all for any help with this! /AZ

2

2 Answers

1
votes

Introduction of expressions is in: http://msdn.microsoft.com/en-us/library/ee342461.aspx under "Expressions – acting on data".

A sample is available in: http://msdn.microsoft.com/en-us/library/dd699761.aspx

The expression language is full VB.NET 4.0, with WF argument and variable names resolved automatically.

1
votes

If you write the workflow in C# instead of using the editor, you don't have to use Visual Basic. For example, to write a number to the console

new WriteLine { Text = ExpressionServices.Convert( e => new Random.Next() ) }

Or to write a Variable such as Variable<int> Number

new WriteLine { Text = ExpressionServices.Convert ( e => Number.Get(e) ) }

Note that

new WriteLine { Text = new Random.Next() }

will write the same number for every workflow instance which in this case would be undesirable.

Ok, so this approach is a little wordy. WF has its limitations. The other option is to upgrade to .Net 4.5 RC which just came out and supposedly lets you write C# expressions in the editor. Also buy a book, the online WF documentation is poor.