File tree 4 files changed +14
-15
lines changed
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 ;
2
2
using Orleans . Concurrency ;
3
3
using Orleans . Transactions . Abstractions ;
4
4
5
5
namespace AccountTransfer . Grains ;
6
6
7
- [ GenerateSerializer ]
7
+ [ GenerateSerializer , Immutable ]
8
8
public record class Balance
9
9
{
10
- [ Id ( 0 ) ]
11
- public int Value { get ; set ; } = 1_000 ;
10
+ public int Value { get ; init ; } = 1_000 ;
12
11
}
13
12
14
13
[ Reentrant ]
@@ -22,7 +21,7 @@ public AccountGrain(
22
21
23
22
public Task Deposit ( int amount ) =>
24
23
_balance . PerformUpdate (
25
- balance => balance . Value += amount ) ;
24
+ balance => balance with { Value = balance . Value + amount } ) ;
26
25
27
26
public Task Withdraw ( int amount ) =>
28
27
_balance . PerformUpdate ( balance =>
@@ -35,7 +34,7 @@ public Task Withdraw(int amount) =>
35
34
$ " This account has { balance . Value } credits.") ;
36
35
}
37
36
38
- balance . Value -= amount ;
37
+ return balance with { Value = balance . Value + amount } ;
39
38
} ) ;
40
39
41
40
public Task < int > GetBalance ( ) =>
Original file line number Diff line number Diff line change 1
1
<Project >
2
2
<PropertyGroup >
3
- <TargetFramework >net8 .0</TargetFramework >
3
+ <TargetFramework >net9 .0</TargetFramework >
4
4
<ImplicitUsings >enable</ImplicitUsings >
5
5
<Nullable >enable</Nullable >
6
6
</PropertyGroup >
Original file line number Diff line number Diff line change 4
4
<ManagePackageVersionsCentrally >true</ManagePackageVersionsCentrally >
5
5
</PropertyGroup >
6
6
<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 " />
14
14
</ItemGroup >
15
15
</Project >
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public Task Withdraw(uint amount) => _balance.PerformUpdate(x =>
89
89
90
90
## Sample prerequisites
91
91
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.
93
93
94
94
## Building the sample
95
95
You can’t perform that action at this time.
0 commit comments