Catégorie : Linq

Linq – Remplir une liste déroulante (DropDownList)

var query = from m in data.menu
join p in data.page on m.menu_page_id equals p.id
group p by new { m.menu_txt , menuId = m.id, pid = p.id, } into g
select new { g.Key.menu_txt, g.Key.pid, g.Key.menuId };
int b = 0;
foreach (var i in query)
{
DropDownList1.Items.Add(i.menu_txt);
DropDownList1.Items[b].Value = i.menuId.ToString();
b++;
})

Guid client_id = Guid.Empty;
Data.Entities bdd = new Data.Entities();
var recupClient = from cli in bdd.Client
join fact in bdd.Facture on cli.cli_id equals fact.fact_client_id
where fact.fact_id == _facture_id
select cli;

foreach (var i in recupClient)
{
System.
Type type = i.GetType();
client_id = (Guid)type.GetProperty(« cli_id »).GetValue(i, null);
}