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


C# IQueryable.Select方法代码示例

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


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

示例1: getStatsFor

 private IQueryable<Stats> getStatsFor(IQueryable<IGrouping<string, Order>> query)
 {
     return query.Select(y => new Stats {
         Key = y.Key,
         Count = y.Count()
     }).Select(e => e);
 }
开发者ID:Schniz,项目名称:colman-store,代码行数:7,代码来源:AdminStatsController.cs

示例2: FindPageOfMovies

        public static IEnumerable<FullViewModel> FindPageOfMovies(IQueryable<FullViewModel> res,
                                                    int page,
                                                    int movie_count,
                                                    MovieDbContext db,
                                                    bool verbose=false)
        {
            var page_start = Tools.WriteTimeStamp(writeTime:false);
            if (verbose) { Tools.TraceLine("  Retrieving paginated results"); }

            int movies_to_skip = movie_count * (page - 1);
            var ids = res.Select(nit => nit.Movie.movie_ID).ToArray();

            if (verbose) { Tools.TraceLine("  sorting movie ids"); }
            //take all the movie_id up to and including the ones you'll show
            // on page, then only take the last set of movie_ids you'll show
            var sortedIds =
                ids.OrderBy(movie_id => movie_id)
                   .Skip(movies_to_skip)
                   .Take(movie_count)
                   .ToArray();

            if (verbose) { Tools.TraceLine("  grabbing matched movies"); }
            var nit_qry =
                Tools.GetFullDbQuery(db)
                     .Where(
                         viewModel =>
                         sortedIds.Any(
                             movie_id => movie_id == viewModel.Movie.movie_ID));
            IEnumerable<FullViewModel> nit_list = nit_qry.ToList();
            if (verbose) { Tools.TraceLine("  done matching movies, returning"); }
            var page_end = Tools.WriteTimeStamp(writeTime:false);
            if (verbose) { Tools.TraceLine("  Taking first page of movies {0}", (page_end - page_start).ToString()); }
            return nit_list;
        }
开发者ID:tankorsmash,项目名称:NextFlickMVC4_Git,代码行数:34,代码来源:MoviesController.cs

示例3: ArticleModelEditViewManagement

        public ArticleModelEditViewManagement(IQueryable<Data.User> users)
        {
            AvailablePostprocessors = ProcessorHelper.GetPostprocessors()
                .ToDictionary(ppType => ppType.AssemblyQualifiedName, ppType => ppType.GetProcessorDisplayName());

            AvailableAuthors = users
                .Select(u => new SelectListItem { Value = u.UserId.ToString(), Text = u.DisplayName, });
        }
开发者ID:obscuredesign,项目名称:web,代码行数:8,代码来源:ArticleModel.cs

示例4: ConnectTagsToArticle

 public static void ConnectTagsToArticle(this DbSet<ArticleTag> source, Article article, IQueryable<Tag> tags)
 {
     var articleTags = tags.Select(t => new ArticleTag
     {
         ArticleId = article.ArticleId,
         TagId = t.TagId,
     }).ToList();
     source.AddRange(articleTags);
 }
开发者ID:obscuredesign,项目名称:web,代码行数:9,代码来源:ArticleTag.cs

示例5: GetSearchSuggestionSeriesQuery

 public IQueryable<SerieItemModel> GetSearchSuggestionSeriesQuery(IQueryable<Serie> query)
 {
     IQueryable<SerieItemModel> series = query.Select(br => new SerieItemModel
     {
         Id = br.SerieId,
         Name = br.Name,
         Authors = br.BookInSeries.SelectMany(bi=>bi.Book.Authors).Select(a => new AuthorItemModel() { Id = a.AuthorId, Name = a.Name }),
         Rating = new RatingModel { Value = (double?)br.Ratings.Average(r => r.Value) ?? 0 },
         HasImage = false
     });
     return series;
 }
开发者ID:avgx,项目名称:knigoskop,代码行数:12,代码来源:BasicDataService.cs

示例6: GetSearchSuggestionBooksQuery

 public IQueryable<BookItemModel> GetSearchSuggestionBooksQuery(IQueryable<Book> query)
 {
     IQueryable<BookItemModel> books = query.Select(br => new BookItemModel
         {
             Id = br.BookId,
             Name = br.Name,
             Authors = br.Authors.Select(a => new AuthorItemModel() { Id = a.AuthorId, Name = a.Name }),
             Rating = new RatingModel { Value = (double?)br.Ratings.Average(r => r.Value) ?? 0 },
             HasImage = br.Cover != null
         });
     return books;
 }
开发者ID:avgx,项目名称:knigoskop,代码行数:12,代码来源:BasicDataService.cs

示例7: CreateProductListViewModel

 internal PaginatedList<ProductListViewModel> CreateProductListViewModel(IQueryable<Product> source, int PageIndex, int PageSize)
 {
     return new PaginatedList<ProductListViewModel>(source.Select(
          p => new ProductListViewModel
          {
              ProductId = p.Id,
              ImageFileName = p.ImageFileNames.First().FileName,
              ProductTitle = p.Title,
              Price = GetPrice(p.Id)
          }),
          PageIndex, PageSize);
 }
开发者ID:linkinmal,项目名称:AntikaMarketim,代码行数:12,代码来源:ProductBusiness.cs

示例8: GetSearchSuggestionAuthorsQuery

 public IQueryable<AuthorItemModel> GetSearchSuggestionAuthorsQuery(IQueryable<Author> query)
 {
     IQueryable<AuthorItemModel> authors = query.Select(ar => new AuthorItemModel
         {
             Id = ar.AuthorId,
             Name = ar.Name,
             BornYear = ar.BirthDate != null ? ar.BirthDate.Value.Year : (int?)null,
             DeathYear = ar.DeathDate != null ? ar.DeathDate.Value.Year : (int?)null,
             Rating = new RatingModel { Value = (double?)ar.Ratings.Average(r => r.Value) ?? 0 },
             HasImage = ar.Photo != null,
             BooksCount = ar.Books.Count()
         });
     return authors;
 }
开发者ID:avgx,项目名称:knigoskop,代码行数:14,代码来源:BasicDataService.cs

示例9: Create

        public RestaurantModel Create(DataRow restaurant, IQueryable<DataRow> reviews)
        {
            return new RestaurantModel()
                {
                    //Url = RestaurantUrl(restaurant),
                    ID = (int)restaurant["ID"],
                    Name = restaurant["Name"].ToString(),
                    Created = (DateTime)restaurant["AddDate"],

                    Address = _addressModelFactory.Create(
                        restaurant["City"].ToString(), restaurant["state"].ToString(),
                        restaurant["country"].ToString(), restaurant["street"].ToString()),
                    ImgUrl = "../../Content/images/restaurant1.jpg",
                    Reviews = reviews.Select(rr => _reviewModelFactory.Create(rr))
                };
        }
开发者ID:vadpetrov,项目名称:Pluralsight,代码行数:16,代码来源:RestaurantModelFactory.cs

示例10: BuildPolyExpression

        private IQueryable<int> BuildPolyExpression(IQueryable<int> parent, int depth)
        {
            if (depth == 0)
                return parent;

           var expr = parent.Select(x => new {depth, x})
                .Where(y => y.x > 10 && y.x/10 > 100)
                .OrderBy(z => z.depth)
                .ThenBy(q => q.depth)
                .ThenByDescending(a => a.x)
                .Take(100)
                .Skip(10)
                .Distinct()
                .Cast<int>();

            return BuildPolyExpression(expr, depth - 1);
        }
开发者ID:vik-borisov,项目名称:VikExpressionTreeVisualizer,代码行数:17,代码来源:UnitTest1.cs

示例11: buildInmateVM

 // buildInmatesVM is separate from GetActiveInmates to allow creating
 //   multiple search api methods such as by facility or by sending a
 //   list of inmate_id's. The SQL query isn't made until the ToList( )
 //   function is called, so this is still efficient.
 private List<InmateVM> buildInmateVM(IQueryable<Inmate> inmateQuery) {
     List<InmateVM> inmateList =
         inmateQuery.Select(inmate => new InmateVM() {
             Id = inmate.inmate_id,
             Number = inmate.inmate_number,
             FirstName = inmate.Person.person_first_name,
             MiddleName = inmate.Person.person_middle_name,
             LastName = inmate.Person.person_last_name,
             Age= inmate.Person.person_age,
             Dob = inmate.Person.person_dob,
             FacilityName = inmate.Facility.Facility_Name,
             Recieved = inmate.inmate_received_date,
             Release = inmate.inmate_scheduled_release_date,
             Status = inmate.inmate_status,
         }).ToList();
     return inmateList;
 }
开发者ID:alshtrike,项目名称:atimsjms,代码行数:21,代码来源:InmatesController.cs

示例12: GetPattern

        public static string GetPattern(IQueryable<ChatUserMention> mentions)
        {
            // Rebuild if nothing is cached
            if (_customCachedPattern == null || _customCachedPatternMentions == null)
                return UpdatePattern(mentions.ToList());

            // Check all the users are in the pattern
            var addedCount = mentions.Count(p => !_customCachedPatternMentions.Contains(p.Key));
            if (addedCount > 0)
            {
                return UpdatePattern(mentions.ToList());
            }

            var currentKeys = mentions.Select(p => p.Key).ToList();

            var removedCount = _customCachedPatternMentions.Where(p => !currentKeys.Contains(p)).Count();

            return removedCount > 0 ? UpdatePattern(mentions.ToList()) : _customCachedPattern;
        }
开发者ID:Widdershin,项目名称:vox,代码行数:19,代码来源:MentionExtractor.cs

示例13: PopulateDropDownLists

        public async Task PopulateDropDownLists(IQueryable<Author> authors, IQueryable<Collection> collections)
        {
            (AvailableAuthors as List<SelectListItem>).AddRange(await authors.Select(a => new SelectListItem
            {
                Text = a.LastName + ", " + a.FirstName,
                Value = a.Id.ToString(),
                Selected = Document.AuthorId == a.Id
            }).ToListAsync());

            (AvailableCollections as List<SelectListItem>).AddRange((await collections
                .ToListAsync())
                .Select(c => new TranslatedViewModel<Collection, CollectionTranslation>(c))
                .Select(c => new SelectListItem
                {
                    Selected = c.Entity.Id == Document.CollectionId,
                    Value = c.Entity.Id.ToString(),
                    Text = c.Entity.CatalogCode + " - " + "'" + c.Translation.Title + "'"
                }));
        }
开发者ID:RedRoserade,项目名称:arquivo-silva-magalhaes,代码行数:19,代码来源:DocumentViewModels.cs

示例14: Select

        private IQueryable<ProductWeb> Select(IQueryable<ProductCulture> _PC, int CurrencyID, ApplicationDbContext _c)
        {
            return _PC.Select(m => new ProductWeb
            {
                AdditionalInformation = m.AdditionalInformation,
                Description = m.Description,
                FriendlyUrl = m.FriendlyUrl,
                IconPath = m.IconPath,
                ProductName = m.ProductName,
                ProductID = m.ProductID,
                CultureName = m.Culture.Name,
                New = m.Product.New,
                Featured = m.Product.Featured,
                Galleries = m.Product.ProductGalleries.Select(m2 => new ProductGalleryBinding
                {
                    PhotoPath = m2.PhotoPath
                }).ToList(),

                //TO-DO OPTIMIZE ME
                Price = (CurrencyID == 0 || !m.Product.ProductCurrencies.Where(p => p.CurrencyID == CurrencyID).Any())
                ? (m.Product.ProductCurrencies.Any()
                    ? m.Product.ProductCurrencies.FirstOrDefault().Price
                    : 0)
                : m.Product.ProductCurrencies.Where(p => p.CurrencyID == CurrencyID).FirstOrDefault().Price,

                PriceOld = (CurrencyID == 0 || !m.Product.ProductCurrencies.Where(p => p.CurrencyID == CurrencyID).Any())
                ? (m.Product.ProductCurrencies.Any()
                    ? m.Product.ProductCurrencies.FirstOrDefault().PriceOld
                    : 0)
                : m.Product.ProductCurrencies.Where(p => p.CurrencyID == CurrencyID).FirstOrDefault().PriceOld,

                Sale = (CurrencyID == 0 || !m.Product.ProductCurrencies.Where(p => p.CurrencyID == CurrencyID).Any())
                ? (m.Product.ProductCurrencies.Any()
                    ? m.Product.ProductCurrencies.FirstOrDefault().PriceOld > 0
                        ? true
                        : false
                    : false)
                : (m.Product.ProductCurrencies.Where(p => p.CurrencyID == CurrencyID).FirstOrDefault().PriceOld > 0)
                    ? true
                    : false
            });
        }
开发者ID:ansarbek,项目名称:thewall9-CMS,代码行数:42,代码来源:ProductBLL.cs

示例15: GetModelDetail

        private ActionResult GetModelDetail(IQueryable<SysUser> model, int pageIndex, int pageSize)
        {
            var result = model.Select(a => new
            {
                a.Id,
                a.UserId,
                a.CreatedDate,
                a.DisplayName,
                a.MobilePhone,
                a.Picture,
                a.Enabled,
                a.Email,
                a.UserName,
                DepartmentName = a.SysDepartmentSysUsers.Select(b => b.SysDepartment.DepartmentName),
                RoleName = a.SysRoleSysUsers.Select(b => b.SysRole.RoleName),
                a.Remark
            }).ToPagedList(pageIndex, pageSize);

            return Content(JsonConvert.SerializeObject(result));
        }
开发者ID:b9502032,项目名称:MySite,代码行数:20,代码来源:ColleagueController.cs


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