When running from local machine at Sql Server on Docker some queries get broken because the TimeZone.
At PedidoAPI:
But there are items at Database:
So, sending the "DateTime.Now" from API Backend it works:
public async Task<PedidoDTO> ObterUltimoPedido(Guid clienteId)
{
const string sql = @"SELECT
P.ID AS 'ProdutoId', P.CODIGO, P.VOUCHERUTILIZADO, P.DESCONTO, P.VALORTOTAL,P.PEDIDOSTATUS,
P.LOGRADOURO,P.NUMERO, P.BAIRRO, P.CEP, P.COMPLEMENTO, P.CIDADE, P.ESTADO,
PIT.ID AS 'ProdutoItemId',PIT.PRODUTONOME, PIT.QUANTIDADE, PIT.PRODUTOIMAGEM, PIT.VALORUNITARIO
FROM PEDIDOS P
INNER JOIN PEDIDOITEMS PIT ON P.ID = PIT.PEDIDOID
WHERE P.CLIENTEID = @clienteId
AND P.DATACADASTRO between DATEADD(minute, -30, @Now) and @Now
ORDER BY P.DATACADASTRO DESC";
var pedido = await _pedidoRepository.ObterConexao()
.QueryAsync<dynamic>(sql, new { clienteId, Now = DateTime.Now });
if (!pedido.Any())
return null;
return MapearPedido(pedido);
}
Can I make a suggestion? I work with multi time zone application and the best solution is to work everything in UTC. Just like the plane works, that ZULU
When running from local machine at Sql Server on Docker some queries get broken because the TimeZone.
At PedidoAPI:
But there are items at Database:
So, sending the "DateTime.Now" from API Backend it works: