日期:2014-05-20 浏览次数:20886 次
SQL:
SELECT TOP 1 min(id) BAGID FROM A group by id having count(id)=1 ORDER BY id ASC
var query=( from a in db.A
group a by a.id into g
where g.Count()==1
order by g.Key
select new {BAGID =g.Min(x=>x.id)}).FirstOrDefault();