1

我有这个 Linq-to-Entities 表达式

return
                (from aa in DataContext.AccommodationAmenities
                 join a in DataContext.Amenities
                     on aa.AmenityId equals a.Id
                 where a.LowerCaseAmenity.Contains(lowerCaseSearchTerm)
                 select new AmenitySummary
                            {
                                AmenityId = a.Id,
                                Amenity = a.Amenity1,
                                LowerCaseAmenity = selected//a.LowerCaseAmenity
                            }).Distinct();

而且我还有一个字符串数组,其中包含我想从这个列表中排除的设施。最后有没有办法做这样的事情

.Exclude(a => a.Amentiy == stringArray)

所以基本上,stringArray 包含一些设施,其中一些将等于 AmenitySummary 中的 Amenity。如果它们相等,我不想将其添加到结果中。

4

1 回答 1

0

尝试以下操作:

return
                (from aa in DataContext.AccommodationAmenities
                 join a in DataContext.Amenities
                     on aa.AmenityId equals a.Id
                 where a.LowerCaseAmenity.Contains(lowerCaseSearchTerm)
                       && !stringArray.Contains(a.Amenity1)
                 select new AmenitySummary
                            {
                                AmenityId = a.Id,
                                Amenity = a.Amenity1,
                                LowerCaseAmenity = selected//a.LowerCaseAmenity
                            }).Distinct();
于 2012-09-03T16:53:10.287 回答