2
I have a table with the following schematics:
GarantiaImovel | imovelID | GarantiasTipos
12 | 3 | Caução2
12 | 4 | Depósito
12 | 5 | Caução2
12 | 5 | Fiador
12 | 5 | Seguro Fiança
So I have the following Query
:
var garantias = (from p in db.T_GarantiasLocaticias
where p.imovelID == 5
select p.GarantiasTipos).ToList();
My intention in this Query
is to return the three rows in the table above with the column GaantiasTipo
, but me using the foreach
and it only returns me the last line as I can return in the following structure:
foreach (var garantia in garantias)
{
lblGarantiaLocaticias.Text = garantia + ", ";
}
How to proceed?
You could just use one
+=
. Thus:lblGarantiaLocaticias.Text += garantia + ", ";
. Theforeach
will be produced in any way, either explicitly or in thestring.Join
.– Jéf Bueno