entity framework - How to write this Query in LINQ -
i have 1 linq query foreach loop. fine. takes more time value. suggest me how can in linq query itself.
code
normvalue = ""; c = 0; var normvaluelist = db.bcont.where(x => x.bid == bid && x.tno == tag).tolist(); foreach (var item in normvaluelist) { if (c == 0) normvalue = item.normvalue; else normvalue += " " + item.normvalue; c = 1; } thanks
you can rewrite query string.join avoid creating multiple string objects in loop, this:
string normvalue = string.join(" ", db.bcont.where(x => x.bid == bid && x.tno == tag)); the number of round-trips db remain same, creation of list<string> , partially concatenated string objects optimized out.
Comments
Post a Comment