c# - How to use two variables in a foreach loop? -
i using dotconnect linq sqlite. want use 2 variable in foreach loop. followed this code not working. code snippet.
bool check_units(int id) { maindatacontext medic = new maindatacontext(); bool check = false; var medic_query = m in medic.medicines orderby m.id m.id == id select m; var invo_query = inv in medic.invoices orderby inv.id inv.id == id select inv; var med_inv = medic_query.zip(invo_query, (m, i) => new { medicine = m, invoice = }); foreach(var mi in med_inv) { if (mi.medicine.unit > mi.invoice.unit) { mi.medicine.unit -= mi.invoice.unit; if (mi.medicine.unit < 10) { messagebox.show(mi.medicine.name + " short in invertory!\nunits remaining: " + mi.medicine.unit, "inventory empty", messageboxbuttons.ok, messageboxicon.exclamation); } chk = true; } else { messagebox.show("not enough stock!\nunits remaining: " + mi.medicine.unit, "inventory short", messageboxbuttons.ok, messageboxicon.error); } } medic.submitchanges(); return chk; }
the problem facing code gives error
the query operator 'zip' not supported.
there no kind of syntax error or warning. think zip operator can not used linqtosql type of queries!
waiting support! :)
the problem underlying query provider cannot translate zip
method raw sql. since you're not applying additional filters simplest method hydrate query using asenumerable
:
var med_inv = medic_query.asenumerable() .zip(invo_query, (m, i) => new { medicine = m, invoice = });
are records each query line properly? looks should join
since don't specify if/how records related can't tell proper join be.
Comments
Post a Comment