Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade bank account sample #7011

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions orleans/BankAccount/AccountTransfer.Grains/AccountGrain.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using AccountTransfer.Interfaces;
using AccountTransfer.Interfaces;
using Orleans.Concurrency;
using Orleans.Transactions.Abstractions;

namespace AccountTransfer.Grains;

[GenerateSerializer]
[GenerateSerializer, Immutable]
public record class Balance
{
[Id(0)]
public int Value { get; set; } = 1_000;
public int Value { get; init; } = 1_000;
}

[Reentrant]
Expand All @@ -22,7 +21,7 @@ public AccountGrain(

public Task Deposit(int amount) =>
_balance.PerformUpdate(
balance => balance.Value += amount);
balance => balance with { Value = balance.Value + amount });

public Task Withdraw(int amount) =>
_balance.PerformUpdate(balance =>
Expand All @@ -35,7 +34,7 @@ public Task Withdraw(int amount) =>
$" This account has {balance.Value} credits.");
}

balance.Value -= amount;
return balance with { Value = balance.Value + amount };
});

public Task<int> GetBalance() =>
Expand Down
2 changes: 1 addition & 1 deletion orleans/BankAccount/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
14 changes: 7 additions & 7 deletions orleans/BankAccount/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="Microsoft.Orleans.Client" Version="8.0.0" />
<PackageVersion Include="Microsoft.Orleans.Sdk" Version="8.0.0" />
<PackageVersion Include="Microsoft.Orleans.Server" Version="8.0.0" />
<PackageVersion Include="Microsoft.Orleans.Transactions" Version="8.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Client" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Sdk" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Server" Version="9.0.1" />
<PackageVersion Include="Microsoft.Orleans.Transactions" Version="9.0.1" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion orleans/BankAccount/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Task Withdraw(uint amount) => _balance.PerformUpdate(x =>

## Sample prerequisites

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.
This sample is written in C# and targets .NET 7.0. It requires the [.NET 9.0 SDK](https://dotnet.microsoft.com/download/dotnet/9.0) or later.
IEvangelist marked this conversation as resolved.
Show resolved Hide resolved

## Building the sample

Expand Down
Loading