取得的效果是筛选不重复记录,以手机号码为准,重复的只取一条,
我写的SQL
select * from Proxy a where ID=(select min(ID) from Proxy where [Mobile ]=a.[Mobile ]) order by Id descvar proxyClones = (from q in query where q.Id == _proxyRepository.Table.Where(c => c.Mobile == q.Mobile).Min(c => c.Id) select new ProxyClone() { Id = q.Id, });
一直报连接超时的错误
这个是我原来写的去重,速度很慢
var proxyClones = (from q in query
select new ProxyClone()
{
Id = q.Id,
CreateTime = q.CreateTime,
}).GroupBy(g => new { g.Mobile }).Select(s => s.FirstOrDefault());
你的数据表有多少记录数?
mobile字段是否有建立索引?
为什么要Select *,你查出来几十几百万条记录有什么意义呢?
索引没有建立,分页了,也是按需查询,我把SQL的使用内存调大了,速度上去了。