Can I use a LINQ Query such as the following in a Workflow?
private static void ShowQueryWithCode(IEnumerable<string> names){ Console.WriteLine("Linq Query in Code - show names that start with 'R'"); // Assuming there are no null entries in the names collection var query = from name in names where name.StartsWith("R") select name; // This is the same thing as // var query = names.Where(name => name.StartsWith("R")); foreach (var name in query) { Console.WriteLine(name); } Console.WriteLine();}
private static void ShowQueryWithCode(IEnumerable<string> names){ Console.WriteLine("Linq Query in Code - show names that start with 'R'"); // Assuming there are no null entries in the names collection var query = from name in names where name.StartsWith("R") select name; // This is the same thing as // var query = names.Where(name => name.StartsWith("R"));
foreach (var name in query) { Console.WriteLine(name); } Console.WriteLine();}
Yes, you can use LINQ with a Workflow in exactly the same way.
Here you can see that I've added the in argument
Before you can add a variable you need to include an activity which has variables. In this workflow I've added a sequence.
You can use a method chain or query syntax.
In the completed workflow I used a ForEach<string> activity to iterate the list of names and write them to the console.
This example uses C# in .NET 4.5 but the same technique can be used with Visual Basic.
When you run it you can see that both methods work the same.
Happy Coding!
Ron Jacobs http://blogs.msdn.com/rjacobs Twitter: @ronljacobs
Hi Ron,
Sorry to post my question under this topic, as I am not sure where i can post my question without searching the blogs.
Here i go..
I am creating workflows dynamically for each project based on the tasks defined for projects in database. Its working fine as long as i don't modify the tasks for any project like adding new task and removing the existing task for the workflow tree for a project. When I make changes to the workflow tree that time I see error msg like 'workflow tree is not matching with persisted instance'.
To make it more clear:
1. I am creating workflow pro-grammatically based on the tasks defined in database for a project.
2. During the execution of project, I am adding new task or removing task from the that particular project in database
3. When i resume and load the instance with new modified workflow tree schema, it throws error.
My Question is :
How can i handle such situation with same instance ID?
Regards,
Mahendra