У меня есть прототип файла со следующими данными:
TestGRP C .proto:
syntax = "proto3";
option csharp_namespace = "MyGRPC";
package MyApi;
service Author {
rpc GetArticles (ArticleRequest) returns (ArticleResponse);
}
message ArticleRequest {
int32 articleId = 1;
int32 countryId = 2;
string userCookieId = 3;
}
message ArticleResponse {
int32 ArticleId = 1;
string Title = 2;
repeated TaxTagsResponse RelatedTaxTags = 3;
}
message TaxTagsResponse{
int32 TaxTagId = 1;
string DisplayName = 2;
}
Это используется в asp. net core 3.1 gRP C клиентский проект, который имеет классы DTO со следующей структурой:
public class ArticleDTO
{
public int ArticleId
{
get;
set;
}
public List<TaxTagsDTO> RelatedTaxTags
{
get;
set;
}
}
public class TaxTagsDTO
{
public int? TaxTagId
{
get;
set;
}
public int? ParentTagId
{
get;
set;
}
public int? CountryId
{
get;
set;
}
[JsonProperty("displayname")]
[RegularExpression(Constants.GeneralStringRegularExpression)]
public string DisplayName
{
get;
set;
}
public int? LanguageId
{
get;
set;
}
public List<CountryDTO> RelatedCountries
{
get;
set;
}
}
public class MappingProfile : Profile
{
public MappingProfile()
{
CreateMap<ArticleResponse, ArticleDTO>().ForMember(dest => dest.RelatedTaxTags, opt => opt.MapFrom(src => src.RelatedTaxTags));
}
}
public class ArticleService : IArticleService
{
private readonly IOptions<UrlsConfig> _appSettings;
private readonly HttpClient _httpClient;
private readonly ILogger<ArticleService> _logger;
private readonly IMapper _mapper;
public ArticleService(HttpClient httpClient, IOptions<UrlsConfig> appSettings, ILogger<ArticleService> logger, IMapper mapper)
{
_appSettings = appSettings;
_httpClient = httpClient;
_logger = logger;
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
}
public async Task<ArticleDTO> GetArticleAsync(int articleId, int countryId, string userCookieId)
{
return await GrpcCallerService.CallService(_appSettings.Value.GrpcAuthor, async channel =>
{
var client = new AuthorGRPC.Author.AuthorClient(channel);
var response = await client.GetArticlesAsync(new ArticleRequest{ArticleId = articleId, CountryId = countryId, UserCookieId = userCookieId});
_logger.LogDebug("grpc response {@response}", response);
var articleResponse = _mapper.Map<ArticleDTO>(response);
return articleResponse;
});
}
}
Может ли кто-нибудь помочь мне здесь, предоставив свои рекомендации по устранению этой проблемы.