假设我想按国家/地区对我的客户数据库进行排名。在SQL中我会写:selectCountryID,CustomerCount=count(*),[Rank]=RANK()over(orderbycount(*)desc)fromCustomer现在我想在EntityFramework中写这个:varranks=db.Customers.GroupBy(c=>c.CountryID).OrderByDescending(g=>g.Count()).Select((g,index)=>new{CountryID=g.Key,CustomerCount=g.Count,Rank=index+1
连续编码48小时,我正在用头撞墙。请帮我解决这个小问题。我的SQL查询是这样的:SELECTu.Firstname,u.Lastname,u.Rep,u.Email,u.Password,u.Gender,u.Level,u.Birthday,u.Achievements,u.Height,u.Unit,u.cityid,u.countryid,r.RegDate,ci.NameASCity,co.NameASCountryFROMUsersu,Registryr,Citiesci,CountriescoWHEREu.id=1ANDr.uid=u.idANDu.cityid=ci.id