我正在尝试根据 distinct 过滤记录。我使用了以下代码
List<BALHotelList> searchresult = (from a in bh
join b in hr on a.HotelCode equals b.hotelCode
orderby a.HotelName
select new BALHotelList
{
HotelCode = a.HotelCode,
ImageURL_Text = a.ImageURL_Text,
HotelName = a.HotelName,
StarRating = a.StarRating,
HotelAddress = a.HotelAddress,
Destination = a.Destination,
Country = a.Country,
HotelInfo = a.HotelInfo,
Latitude = a.Latitude,
Longitude = a.Longitude,
HotelArea=a.HotelArea,
totalPrice = b.totalPrice,
totalPriceSpecified = b.totalPriceSpecified,
totalSalePrice = b.totalSalePrice,
totalSalePriceSpecified = b.totalSalePriceSpecified,
rooms = b.rooms,
boardType = b.boardType
}).ToList();
var uniqueArea =searchresult.Select(m => m.HotelArea).Distinct();
rptHotelArea.DataSource = uniqueArea;
rptHotelArea.DataBind();
但它没有在数据源中找到 HotelArea 。
但是当我调试它时,它会显示我所有不同的值uniqueArea
错误如下:
DataBinding: 'System.String' does not contain a property with the name 'HotelArea'.
已编辑
这是中继器 HTML
<asp:Repeater ID="rptHotelArea" runat="server">
<ItemTemplate>
<div class="sub-part1">
<a href="#"><%#Eval("HotelArea")%></a></div>
</ItemTemplate>
</asp:Repeater>