本文介绍了如何解决的&QUOT的错误信息;无法隐式转换类型Generic.IEnumerable<&型GT;'以“Generic.List<&型GT;"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我收到此错误信息:

when I build this code:

 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,
                       totalPrice = b.totalPrice,
                       totalPriceSpecified = b.totalPriceSpecified,
                       totalSalePrice = b.totalSalePrice,
                       totalSalePriceSpecified = b.totalSalePriceSpecified,
                       rooms = b.rooms

                    };
解决方案

You may just need to wrap your linq with some parentheses and call .ToList on the result:

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,
                   totalPrice = b.totalPrice,
                   totalPriceSpecified = b.totalPriceSpecified,
                   totalSalePrice = b.totalSalePrice,
                   totalSalePriceSpecified = b.totalSalePriceSpecified,
                   rooms = b.rooms

                }).Tolist();

这篇关于如何解决的&QUOT的错误信息;无法隐式转换类型Generic.IEnumerable&LT;&型GT;'以“Generic.List&LT;&型GT;&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 13:04