Expressions

This sample demonstrates how to use basic expressions in a workflow. It consists of a workflow that calculates basic salary statistics for two employees of a fictitious company. Two classes, Employee and SalaryStats, are defined in Employee.cs and SalaryStats.cs. These classes are used in a workflow that shows how to perform simple arithmetic and string operations on properties of variables of complex types.

The salary calculation workflow is defined both in XAML and in C# to demonstrate the two authoring styles. The XAML version is contained in SalaryCalculation.xaml and can be viewed and edited in the workflow designer. The C# version resides in Program.cs. The expressions used in XAML conform to Visual Basic syntax, and use VisualBasicValue and VisualBasicReference expression activities to execute. For more information about Visual Basic expressions see, Visual Basic Expressions. On the other hand, expressions in C# are written as lambda expressions and use LambdaValue and LambdaReference expression activities. Writing expressions as lambda expressions allows the C# compiler to provide syntax highlighting and static verification. For more information about lambda expressions in C#, see Lambda Expressions (C# Programming Guide). If a workflow is authored in code using Visual Basic, then Visual Basic lambda expressions are used. For more information about lambda expressions in Visual Basic, see Lambda Expressions (Visual Basic). For more information about about authoring workflows using code, see Authoring Workflows, Activities, and Expressions Using Imperative Code.

To run the sample

  1. Open the Expressions.sln solution in Visual Studio 2010.

  2. Press CTRL+SHIFT+B to build the solution or select Build Solution from the Build menu.

    noteNote:
    To open SalaryCalculation.xaml in the Visual Studio designer, you must first compile your project to ensure that Employee and SalaryStats classes are available to the designer.

  3. Once the build has succeeded, press F5 or select Start Debugging from the Debug menu. Alternatively you can press Ctrl+F5 or select Start Without Debugging from the Debug menu to run without debugging.

Important Note:
The samples may already be installed on your computer. Check for the following (default) directory before continuing.

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.

<InstallDrive>:\WF_WCF_Samples\WF\Basic\Expressions




Build Date:

2012-08-02
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft