简体   繁体   English

Linq声明OrderBy在DataRow集合上不起作用

[英]Linq statement OrderBy on DataRow collection not working

I have the following business entities and I want to apply LINQ on this. 我具有以下业务实体,并且我想对此应用LINQ。

public class DTPackage
{

    private int _packageID;

    private DTContract _flightComponent;
    private HotelAvailability.HotelCollectionRow _hotelComponent;
    .........
    #region Public Properties
}

public partial class HotelCollectionRow : global::System.Data.DataRow 
{

    private global::System.Data.DataColumn columnSortByEngine;
    private global::System.Data.DataColumn columnDistanceFromLocation;
    private global::System.Data.DataColumn columnSortByDistanceFromLocationGroup;
    private global::System.Data.DataColumn columnIsCommissionBased;
    private global::System.Data.DataColumn columnSortByRank;
    private global::System.Data.DataColumn columnSortByInternalRating;
}

I have written following query but it's not working. 我已经写了以下查询,但是没有用。

My Query 我的查询

 List<DTPackage> filterPackageList = null;
 var query = filterPackageList.AsEnumerable()
             .OrderByDescending(m => m.HotelComponent.DistanceFromLocation);

filterPackageList is full of data. filterPackageList充满数据。

I think that you should try the below solution 我认为您应该尝试以下解决方案

var query = filterPackageList.AsEnumerable()
           .OrderByDescending(m => m.HotelComponent.DistanceFromLocation).ToList(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM