本文介绍了需要将以下sql转换为LINQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 如何将以下sql转换为LINQ SELECT * FROM ( SELECT ROW_NUMBER() OVER ( PARTITION BY CPT4,CPT4MOD,ITEMCHARGE ORDER BY EFF_DATE DESC ) AS RowNo ,* FROM #table ) AS T WHERE T.RowNo = 1 解决方案 假设 dataContainer 是您的数据容器: 列表< yourdataclass> = dataContainer.OrderByDescending(x => x.EFF_DATE).Select((x,i)=> new { Index = i + 1, CPT4 = x.CPT4, CPT4MOD = x.CPT4MOD, ITEMCHARGE = x.ITEMCHARGE, EFF_DATE = x.EFF_DATE })。其中(x => x.Index == 1 )。ToList(); < / yourdataclass > How do I convert the following sql to LINQSELECT *FROM(SELECT ROW_NUMBER() OVER (PARTITION BY CPT4, CPT4MOD, ITEMCHARGE ORDER BY EFF_DATE DESC) AS RowNo , *FROM #table) AS TWHERE T.RowNo = 1 解决方案 Let's say dataContainer is your container for data:List<yourdataclass> = dataContainer.OrderByDescending(x=>x.EFF_DATE).Select((x, i)=>new{ Index = i+1, CPT4 = x.CPT4, CPT4MOD = x.CPT4MOD, ITEMCHARGE = x.ITEMCHARGE, EFF_DATE = x.EFF_DATE }).Where(x=>x.Index==1).ToList();</yourdataclass> 这篇关于需要将以下sql转换为LINQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-11 20:25