Join 2 IQueryable trong .NET

Danh Luu | 3/29/2022 3:43:47 AM

Ta có 2 IQueryable như sau 

IQueryable customerProfiles = _unitOfWork.Repository().Entities;
IQueryable customers = _unitOfWork.Repository().Entities;
var join = customerProfiles.Join(customers,
                    cp => cp.CustomerId,
                    c => c.Id,
                    (customerProfiles, customers) => new GetAllPagedCustomersResponse
                    {
                        Id = customers.Id,
                        FullName = customerProfiles.FullName,
                        PhoneNumber = customers.PhoneNumber,
                        Email = customers.Email,
                        Address = customerProfiles.Address,
                        DateOfBirth = customerProfiles.DateOfBirth,
                        FacePicture = customerProfiles.FacePicture,
                        Gender = customerProfiles.Gender,
                        IdentityNo = customerProfiles.IdentityNo,
                        ProfilePicture = customerProfiles.ProfilePicture,
                        Status = customers.Status,
                        CreatedBy = customers.CreatedBy,
                        CreatedOn = customers.CreatedOn,
                        Description = customerProfiles.Description,
                        FaceImagePath = customerProfiles.FaceImagePath,
                        IdentBackImagePath = customerProfiles.IdentBackImagePath,
                        IdentFrontImagePath = customerProfiles.IdentFrontImagePath,
                        IdentityBacksidePicture = customerProfiles.IdentityBacksidePicture,
                        IdentityFrontPicture = customerProfiles.IdentityFrontPicture,
                        IdentityIssueDate = customerProfiles.IdentityIssueDate,
                        IdentityIssuePlace = customerProfiles.IdentityIssuePlace,
                        IsVerified = customerProfiles.IsVerified,
                        ProfileImagePath = customerProfiles.ProfileImagePath,
                        VerifiedStatus = customerProfiles.VerifiedStatus,
                        LastModifiedOn = customerProfiles.LastModifiedOn,
                        LastModifiedBy = customerProfiles.LastModifiedBy
                    });
                var result = await join.ToPaginatedListAsync(request.PageNumber, request.PageSize);

c# - How to write IQueryable Join using lambda? - Stack Overflow

Expression trong c#: Expression trong LINQ | Comdy

Invoke trong c#: [C#] Invoke là gì? cách sử dụng phương thức Invoke() (laptrinhvb.net)


Tags: C#
Web hosting by Somee.com