Моя ситуация: у меня есть две таблицы: GameRating и Game из двух баз данных.Сначала я выбираю самую рейтинговую игру, например, у меня Count и GameId (тип данных — Guid).
Затем за столом Game, я хочу упорядочить их по количеству GameId. Данные понравятся
Код: Выделить всё
ListGameIdCountResponse { Count = 1, GameId = 'xxxxx-xxxx-xxxx' }
Код: Выделить всё
var ListGameIdCount = string.Join(',', ListGameIdCountResponse.Select(p => $"('{p.GameId}',{p.Count})").ToList());
Код: Выделить всё
ListGameIdCount = ('xxxxx-xxxx-xxxx',10),('xxxxx-bbbb-xxxx',9)
Код: Выделить всё
SELECT g."Name",g."Id"
FROM "Games" g
LEFT JOIN (VALUES {0}) as TrendingGameCount (GameId,Count)
ON g.""Id"" = TrendingGameCount.GameId ::uuid
ORDER BY TrendingGame.Count DESC
Код: Выделить всё
var queryBinding = string.format(query,ListGameIdCount);
Пример
Код: Выделить всё
LEFT JOIN (VALUES "('xxxxx-xxxx-xxxx',1))" as TrendingGameCount (GameId,Count)
Код: Выделить всё
LEFT JOIN (VALUES ('xxxxx-xxxx-xxxx',1)) as TrendingGameCount (GameId,Count)
Подробнее здесь: https://stackoverflow.com/questions/783 ... list-query
Мобильная версия