Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

note Select is used to project elements into a sequence

Đã đóng
#37,178 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@tdykstra đang làm issue này rồi.

Từ ngày 21/5/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

aspnet-core/svc data-access/subsvc Source - Docs.ms
Description

In the section: Loading related data with Select,

I am not sure how the Select function really fits into the context of the differences between eager and lazy loading. (I've always been a little fuzzy here. I just always use eager loading when I need a nav prop filled)

But if this example should go here I would explain the fact that the Selection function being used here projects elements of a sequence into a new form be it a view model or a var variable capable of holding an anonymous type.

Your View Model projection example:

public IList CourseVM { get; set; }

public async Task OnGetAsync()
{
    CourseVM = await _context.Courses
    .Select(p => new CourseViewModel
    {
        CourseID = p.CourseID,
        Title = p.Title,
        Credits = p.Credits,
        DepartmentName = p.Department.Name
    }).ToListAsync();
}

My inline anonymous object example:

 var coursesProjected = await _context.Courses
 .Select(p => new 
 {
     CourseID = p.CourseID,
     Title = p.Title,
     Credits = p.Credits,
     DepartmentName = p.Department.Name
 }).ToListAsync();

coursesProjected has to be of type var here to work.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/read-related-data?view=aspnetcore-10.0&tabs=visual-studio

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/data/ef-rp/read-related-data.md

Document ID

3cb264da-2ff1-1256-572f-aa4ebca6e255

Platform Id

5d8ba75a-678a-21ac-469c-05e8afe24128

Article author

@tdykstra

Metadata
  • ID: d0026f69-7e5d-0d3e-5586-16ecc0656ff0
  • PlatformId: 5d8ba75a-678a-21ac-469c-05e8afe24128
  • Service: aspnet-core
  • Sub-service: data-access

Related Issues

Ngôn ngữ chính
C#
Star
13.1k
Fork
24.5k
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
210

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/AspNetCore.Docs

Tất cả issue của dotnet/AspNetCore.Docs

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.