File tree Expand file tree Collapse file tree 4 files changed +14
-15
lines changed
Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 1- using AccountTransfer . Interfaces ;
1+ using AccountTransfer . Interfaces ;
22using Orleans . Concurrency ;
33using Orleans . Transactions . Abstractions ;
44
55namespace AccountTransfer . Grains ;
66
7- [ GenerateSerializer ]
7+ [ GenerateSerializer , Immutable ]
88public record class Balance
99{
10- [ Id ( 0 ) ]
11- public int Value { get ; set ; } = 1_000 ;
10+ public int Value { get ; init ; } = 1_000 ;
1211}
1312
1413[ Reentrant ]
@@ -22,7 +21,7 @@ public AccountGrain(
2221
2322 public Task Deposit ( int amount ) =>
2423 _balance . PerformUpdate (
25- balance => balance . Value += amount ) ;
24+ balance => balance with { Value = balance . Value + amount } ) ;
2625
2726 public Task Withdraw ( int amount ) =>
2827 _balance . PerformUpdate ( balance =>
@@ -35,7 +34,7 @@ public Task Withdraw(int amount) =>
3534 $ " This account has { balance . Value } credits.") ;
3635 }
3736
38- balance . Value -= amount ;
37+ return balance with { Value = balance . Value + amount } ;
3938 } ) ;
4039
4140 public Task < int > GetBalance ( ) =>
Original file line number Diff line number Diff line change 11<Project >
22 <PropertyGroup >
3- <TargetFramework >net8 .0</TargetFramework >
3+ <TargetFramework >net9 .0</TargetFramework >
44 <ImplicitUsings >enable</ImplicitUsings >
55 <Nullable >enable</Nullable >
66 </PropertyGroup >
Original file line number Diff line number Diff line change 44 <ManagePackageVersionsCentrally >true</ManagePackageVersionsCentrally >
55 </PropertyGroup >
66 <ItemGroup >
7- <PackageVersion Include =" Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version =" 8 .0.0 " />
8- <PackageVersion Include =" Microsoft.Extensions.Hosting" Version =" 8 .0.0 " />
9- <PackageVersion Include =" Microsoft.Extensions.Logging.Console" Version =" 8 .0.0 " />
10- <PackageVersion Include =" Microsoft.Orleans.Client" Version =" 8 .0.0 " />
11- <PackageVersion Include =" Microsoft.Orleans.Sdk" Version =" 8 .0.0 " />
12- <PackageVersion Include =" Microsoft.Orleans.Server" Version =" 8 .0.0 " />
13- <PackageVersion Include =" Microsoft.Orleans.Transactions" Version =" 8 .0.0 " />
7+ <PackageVersion Include =" Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version =" 9 .0.1 " />
8+ <PackageVersion Include =" Microsoft.Extensions.Hosting" Version =" 9 .0.1 " />
9+ <PackageVersion Include =" Microsoft.Extensions.Logging.Console" Version =" 9 .0.1 " />
10+ <PackageVersion Include =" Microsoft.Orleans.Client" Version =" 9 .0.1 " />
11+ <PackageVersion Include =" Microsoft.Orleans.Sdk" Version =" 9 .0.1 " />
12+ <PackageVersion Include =" Microsoft.Orleans.Server" Version =" 9 .0.1 " />
13+ <PackageVersion Include =" Microsoft.Orleans.Transactions" Version =" 9 .0.1 " />
1414 </ItemGroup >
1515</Project >
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public Task Withdraw(uint amount) => _balance.PerformUpdate(x =>
8989
9090## Sample prerequisites
9191
92- This sample is written in C# and targets .NET 7 .0. It requires the [ .NET 7 .0 SDK] ( https://dotnet.microsoft.com/download/dotnet/7 .0 ) or later.
92+ This sample is written in C# and targets .NET 9 .0. It requires the [ .NET 9 .0 SDK] ( https://dotnet.microsoft.com/download/dotnet/9 .0 ) or later.
9393
9494## Building the sample
9595
You can’t perform that action at this time.
0 commit comments