PDA

View Full Version : سوال: معادل این کوئری در linq



forestasphalt
دوشنبه 14 اسفند 1391, 10:21 صبح
string sql = "select top(1) from products where id='" + id + "' UNION ALL select * from products where id not in ('"+id+"') ";
من معادل این کد در لینک میخواستم با تشکر

forestasphalt
دوشنبه 14 اسفند 1391, 10:59 صبح
مشکلم برطرف شد!

var d = (from p in db.Main_Companies join c in db.Main_Companies on p.id equals 2 where c.id == item.id select new { Category = p.title }).Concat(from h in db.Main_Companies where h.id!=item.id select new { Category = h.title });

Sajjad.Aghapour
دوشنبه 14 اسفند 1391, 20:58 عصر
سعی کنید از Union استفاده کنید تا داده های تکراری از لیست نتیجه شما حذف بشن...