Im using Postpre SQL with Dapper
My situation that I have 2 table GameRating and Game from 2 database
first thing I select the most rating game like I have Count and GameId (data type is GuidID)
then at the table Game i want to order by like Count of the GameId
the data will like ListGameIdCountResponse {Count =1,GameId=’xxxxx-xxxx-xxxx’}
then I make the ListGameIdCount into the string like this
var ListGameIdCount = string.Join(‘,’, ListGameIdCountResponse .Select(p => $”(‘{p.GameId}’,{p.Count})”).ToList());
so the query Get Trending Game will like
SELECT g.”Name”,
FROM “Games” g
LEFT JOIN (VALUES {0}) as TrendingGameCount (GameId,Count)
ON g.””Id”” = TrendingGameCount .GameId ::uuid
ORDER BY TrendingGame.Count DESC
The problem im facing now after binding the it have double quote at the value
Example LEFT JOIN (VALUES “(‘xxxxx-xxxx-xxxx’,1))” ) as TrendingGameCount (GameId,Count)
What I want is LEFT JOIN (VALUES (‘xxxxx-xxxx-xxxx’,1)) ) as TrendingGameCount (GameId,Count)
i try to replace or trim the double quote before binding data into query but it not work
Choi Xong Zong is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.