-1

这是我的有效代码:

foreach (var r in rlist)
    {
        if (r.IndexOf("_") != -1)
        {
            int id = int.Parse(r.Split('_')[1]);
            var x_tmp = (from x in db.tblX where x.x_id == my_id && x.x_id == id select x).First();
            x_tmp.order = someNumber;
        }
     }
     db.SaveChanges();

有没有办法重构这个?

4

1 回答 1

0
foreach(var x_tmp in db.tblX.Where(x => rlist.Where(r => r.indexOf("_") != -1).Select(r => Convert.ToInt32(r.Split('_')[1])).Contains(x.x_id)))
     x_tmp = someNumber;
db.SaveChanges();

什么是“my_id”?

于 2012-11-18T17:22:53.683 回答