Ejemplo n.º 1
0
        async Task IVehicleActor.SetVehicleAsync(Vehicle vehicle)
        {
            //Create or Update a Vehicle in its related VehicleActor object
            var resultUpdatingActor = this.StateManager.TryAddStateAsync(VehicleEntityPropertyName, vehicle);

            //Create or Update the same Vehicle into Stateful Services
            //like multiple possible "QueryViews" on Stateful Services using Reliable Collections under the covers.
            //These Stateful services could be multiple "Read/query views" like in CQRS architectures with several "Read-sides"
            FabricClient fabricClient = new FabricClient();
            string       vehiclesStatefulServiceUri         = "fabric:/VehiclesSFApp/VehiclesStatefulService";
            Uri          vehiclesStatefulServiceUriInstance = new Uri(vehiclesStatefulServiceUri);

            long vehiclePartitionKey = vehicle.GetPartitionKey();
            IVehiclesStatefulService vehiclesServiceClient =
                ServiceProxy.Create <IVehiclesStatefulService>(vehiclesStatefulServiceUriInstance,
                                                               new ServicePartitionKey(vehiclePartitionKey));

            bool result = await vehiclesServiceClient.AddOrUpdateVehicleAsync(vehicle);

            return;
        }