2011-03-30 176 views
1

我有一个LINQ查询:LINQ排序排序问题

bikersList = (From c In ngBikersDataContext.Reg_Bikers _ 
       Order By c.L_Name _ 
       Select New Bikers() With { _ 
        .BikerID = c.BikerID, _ 
        .F_Name = c.F_Name, _ 
        .M_Name = c.M_Name, _ 
        .L_Name = c.L_Name, _ 
        .MyID = c.MyID, _ 
        .Site = c.Site.GetValueOrDefault, _ 
        .bk_Building = c.bk_Building, _ 
        .bk_City = c.bk_City, _ 
        .bk_Zip = c.bk_Zip.GetValueOrDefault, _ 
        .bk_Phone = c.bk_phone, _ 
        .email = c.email, _ 
        .DeptZone = c.DeptZone, _ 
        .QuartID = c.QuartID.GetValueOrDefault, _ 
        .BikerDays = c.BikerDays.GetValueOrDefault, _ 
        .BikerMiles = c.BikerMiles.GetValueOrDefault, _ 
        .BikerTime = c.BikerTime.GetValueOrDefault, _ 
        .BKLockID = c.BKLockID.GetValueOrDefault, _ 
        .bk_Start_DT = c.bk_Start_DT, _ 
        .bk_End_DT = c.bk_End_DT, _ 
        .bk_Quarter = c.bk_Quarter.GetValueOrDefault, _ 
        .bk_Year = c.bk_Year.GetValueOrDefault, _ 
        .bk_Comments = c.bk_Comments, _ 
        .IsActive = c.IsActive.GetValueOrDefault _ 
       }).ToList() 

这对L_Name的伟大工程和排序。但我试图让用户排序gridview自己,所以我作为一个字符串传递SortExpression。但我不知道如何将SortExpression引入到LINQ查询中。

我试过Order By c. & SortExpression但没有奏效。

回答