示例#1
0
        public async Task <List <object> > BuscaAsync()
        {
            var retorno = await _dapper.QueryAsync <Veiculo>($@"SELECT *  from veiculo");

            ConcurrentBag <Veiculo> veiculo = new ConcurrentBag <Veiculo>(retorno);

            foreach (var item in veiculo)
            {
                var        queryTwo   = $"SELECT * FROM  marca WHERE id = {item.id_marca}";
                var        queryThree = $"SELECT * FROM  modelo WHERE id = {item.id_modelo}";
                GridReader gridReader = await _dapper.QueryMultipleAsync(queryTwo + " " + queryThree);

                var marca  = gridReader.Read <Marca>().FirstOrDefault();
                var modelo = gridReader.Read <Modelo>().FirstOrDefault();
                item.marca  = marca;
                item.modelo = modelo;
            }

            return(veiculo.AsList <object>());
        }