当前位置: 首页>>代码示例>>C#>>正文


C# PaginatedList.Select方法代码示例

本文整理汇总了C#中PaginatedList.Select方法的典型用法代码示例。如果您正苦于以下问题:C# PaginatedList.Select方法的具体用法?C# PaginatedList.Select怎么用?C# PaginatedList.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PaginatedList的用法示例。


在下文中一共展示了PaginatedList.Select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchLocation

        public Status<BoundBoxSearch> SearchLocation(float lat, float lng, float miles)
        {
            var bounds = Haversine.GetBoundingBox(lat, lng, miles);
            PaginatedList<BuildingPreview> results = null;

            using (var context = new RentlerContext())
            {
                var final = from b in context.Buildings
                            where b.IsActive &&
                                    !b.IsDeleted &&
                                    !b.IsRemovedByAdmin &&
                                    b.Latitude >= bounds.MinLat &&
                                    b.Latitude <= bounds.MaxLat &&
                                    b.Longitude >= bounds.MinLng &&
                                    b.Longitude <= bounds.MaxLng
                            orderby b.BuildingId
                            select new BuildingPreview()
                            {
                                Address1 = b.Address1,
                                Address2 = b.Address2,
                                Bathrooms = b.Bathrooms.Value,
                                Bedrooms = b.Bedrooms.Value,
                                BuildingId = b.BuildingId,
                                RibbonId = b.RibbonId,
                                City = b.City,
                                IsFeatured = false,
                                Price = b.Price,
                                PrimaryPhotoExtension = b.PrimaryPhotoExtension,
                                PrimaryPhotoId = b.PrimaryPhotoId,
                                State = b.State,
                                Title = b.Title,
                                IsActive = b.IsActive,
                                Latitude = b.Latitude,
                                Longitude = b.Longitude,
                                Zip = b.Zip
                            };
                // get the results to show
                results = new PaginatedList<BuildingPreview>(final, 1, int.MaxValue);
            }

            results = new PaginatedList<BuildingPreview>(results
                .Select(z => new KeyValuePair<double, BuildingPreview>(
                    Haversine.GetDistance(lat, lng, z.Latitude, z.Longitude), z))
                .OrderBy(z => z.Key).Select(s => s.Value).AsQueryable(), 1, int.MaxValue);

            return Status.OK(new BoundBoxSearch
            {
                Results = results,
                Bounds = bounds,
                ResultsPerPage = int.MaxValue,
                Page = 1
            });
        }
开发者ID:wes-cutting,项目名称:Sandbox-V2,代码行数:53,代码来源:ISearchAdapter.cs

示例2: Search


//.........这里部分代码省略.........
                    listings = from b in listings
                               where b.SquareFeet >= search.MinSquareFootage
                               select b;
                }

                // Maximum Square Footage is defined
                if (search.MaxSquareFootage.HasValue)
                {
                    listings = from b in listings
                               where b.SquareFeet <= search.MaxSquareFootage
                               select b;
                }

                // Year Built Minimum is defined
                if (search.YearBuiltMin.HasValue)
                {
                    listings = from b in listings
                               where b.YearBuilt >= search.YearBuiltMin
                               select b;
                }

                // Year Built Maximum is defined
                if (search.YearBuiltMax.HasValue)
                {
                    listings = from b in listings
                               where b.YearBuilt <= search.YearBuiltMax
                               select b;
                }

                // Amenities are defined
                if (search.Amenities != null && search.Amenities.Length > 0)
                {
                    listings = from b in listings
                               let ba = b.BuildingAmenities.Select(x => x.AmenityId)
                               where search.Amenities.All(a => ba.Contains(a))
                               select b;
                }

                // Seller Type is defined
                if (search.SellerType != ContactInfoType.Undefined)
                {
                    listings = from b in listings
                               where b.ContactInfo.ContactInfoTypeCode == search.SellerTypeCode
                               select b;
                }

                // Terms
                if (search.Terms != null)
                {
                    // pet friendly
                    if (search.Terms.Contains("petfriendly"))
                    {
                        listings = from b in listings
                                   where b.ArePetsAllowed == true
                                   select b;
                    }

                    // smoking allowed
                    if (search.Terms.Contains("smokingallowed"))
                    {
                        listings = from b in listings
                                   where b.IsSmokingAllowed == true
                                   select b;
                    }
                }
开发者ID:wes-cutting,项目名称:Sandbox-V2,代码行数:66,代码来源:ISearchAdapter.cs


注:本文中的PaginatedList.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。