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

SQL转LINQ问题
SQL code
SELECT ExHotelCode FROM hotel_HotelLinkRelation hhlr 
GROUP BY ExHotelCode,hhlr.GDSCode

哪位大神帮忙写一下这个SQL语句的LINQ表达式啊?

------解决方案--------------------
C# code

 var query = from p in db.hotel_HotelLinkRelation
                group p by p new {ExHotelCode=p.ExHotelCode,GDSCode=p.GDSCode} into g                   
                select new 
                    {
                         g.Key.ExHotelCode, g.Key.GDSCode
                    };

------解决方案--------------------
给一个linq to sql 的学习资料
http://www.cnblogs.com/lovecherry/archive/2007/08/13/853754.html
------解决方案--------------------
改正一下
C# code

public static List<GDSHotelCode> GDSHotelCode()
  {
  HotelDataContext hotelData = new HotelDataContext();

  List<GDSHotelCode> GDSHotelCodelList= (from p in hotelData.hotel_HotelLinkRelation
  group p by new { ExHotelCode = p.ExHotelCode, GDSCode = p.GDSCode } into g
  select new GDSHotelCode()
  {
    g.Key.ExHotelCode,
    g.Key.GDSCode
  }).ToList();
  return GDSHotelCodelList;
  }

------解决方案--------------------
探讨

引用:
改正一下

C# code

public static List<GDSHotelCode> GDSHotelCode()
{
HotelDataContext hotelData = new HotelDataContext();

List<GDSHotelCode> GDSHotelCodelList= (from p in hotelData……