Hi Mohamed,
Thanks for your patience.
We have validated your requirement and created a sample(gRPC integration) based on your requirement. Please find the sample for your reference.
To get started, edit your shared project’s .csproj to add references to the necessary gRPC packages:
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.11.2" />
<PackageReference Include="Grpc.Net.Client" Version="2.29.0" />
<PackageReference Include="Grpc.Tools" Version="2.29.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup> |
Now you can create a .proto file to define your services. Here, we have created weather.proto file inside the shared project.
To make the gRPC tooling generate server and client classes from this, go into your shared project’s .csproj and add the following reference(created weather.proto file).
<ItemGroup>
<Protobuf Include="weather.proto" />
</ItemGroup> |
In the same way, you need to add some reference to your server project’s .csproj. Find the reference list below.
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.29.0" />
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.29.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.0" />
</ItemGroup> |
Then you need to configure the services in Starup.cs file in your server project.
In your client project’s .csproj, you’ll need to add some references(Grpc.Net.Client.Web) like we added in server and shared projects. Find the reference in the provided project and reference link.
Now set up your client app’s dependency injection system to be able to provide instances of WeatherForecastsClient. This will let you invoke the gRPC service from anywhere in your client app. In the client project’s Project.cs file.
Finally we have to call gRPC service from our component file and bind the data to Grid.
Find the below gRPC oriented links for your reference.
Reference:
Please get back to us if you have any concerns.
Regards,
Rahul