Click here to Skip to main content
15,887,214 members
Articles / Database Development / SQL Server

Introducing WF4.0: Building Distributed Apps with WF 4.0 and WF 4.0 Services

Rate me:
Please Sign up or sign in to vote.
4.61/5 (10 votes)
30 Jun 2009CPOL18 min read 77K   2.3K   71  
Shows how to build new-design distributed applications with WF 4.0 and Data Services.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;

namespace CustomActivities
{
    public class BookCar : CodeActivity
    {
        InArgument<string> carId;
        public InArgument<string> CarId
        {
            get { return carId; }
            set { carId = value; }
        }

        protected override void Execute(CodeActivityContext context)
        {
            string carId = CarId.Get(context);

            String urlstr = "http://mhalabi/CarRentalDataService/CarRentalService.svc";
            CarRentalReference.CarStoreEntities proxy = new CarRentalReference.CarStoreEntities(new Uri(urlstr));

            var query = (from c in proxy.Cars
                         where c.CarId == carId
                         select c);

            foreach (CarRentalReference.Car car in query)
            {
                car.Quantity = car.Quantity - 1;
                proxy.UpdateObject(car);
                proxy.SaveChanges();
                break;
            }
            
        }


    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Lebanon Lebanon

Comments and Discussions