日期:2014-05-20  浏览次数:20649 次

怎样以下SQL语句转为LINQ查询?
自己转换了一个,但是得不到期望的结果...
SQL语句:
select top 5	authorName,count(*)
from dbo.authors
group by authorName
having authorName like '赵%'
order by   count(*) desc 


自己转换的LINQ查询:  

  V1DataContext DB = new V1DataContext();
                    var queryName = (from A in DB.authors
                                     group A by new
                                     {
                                         authorName = A.authorName
                                     } into grA
                                     select new
                                     {
                                         authorName = grA.Key.authorName,
                                         Quantity = grA.Count()
                                     } into orderbygrA
                                     where  orderbygrA.authorName.StartsWith("张")
                                     orderby orderbygrA.Quantity descending
                                     select orderbygrA.authorName).Distinct().Take(7);

------解决方案--------------------
给你推荐个Linq工具 LinqPad ,可以把linq查询的语句转成sql
------解决方案--------------------