“Converta LINQ para SQL Query Online” Respostas de código

Converta LINQ para SQL Query Online

 from s in student
                                join lsl in LastStudentLevel on s.UserId equals lsl.UserId
                                join sl in studentLevel on lsl.UserId equals sl.UserId where sl.Session==lsl.AcadYearStr
                                join e in enrollment on s.UserId equals e.UserId
                                where e.EnrollmentAcademicYearId == lsl.AcadYearId
                                join c in course on e.CourseId equals c.CourseId
                                select new StudentInfo
                                {
                                    UserID = s.UserId,
                                    Gender = s.Gender,
                                    FirstName = s.Fname,
                                    LastName = s.Lname,
                                    Funding = s.Funding,
                                    DateOfBirth = s.Dob,
                                    DateOfBirthDateTime = s.DobdateTime,
                                    Email = s.Email,
                                    LevelID = sl.LevelId,
                                    Address = s.HomeAddress,
                                    CourseID = c.CourseId,
                                    CourseName = c.ShortCourseName,
                                    AcademicYear = sl.Session,
                                    ProgressStatus = sl.ProgressStatus,
                                    AwardID = sl.AwardId,
                                    IsGraduated = sl.ProgressStatus == "Completed Studies" ? true : false,
                                    CourseDescription = c.CourseName
                                };
Sardor Ismoilov

Converta LINQ para SQL Query Online

 (from table1 in _context.Clientusercontactdetails
                                           where table1.UserId.Equals(customerServiceData.UserId)
                                           join table2 in _context.Customerservices on table1.ServiceId equals table2.ServiceId
                                           where table2.WorkStatus.Equals(customerServiceData.FilterBy) 
                                           select new { Customerservice = table2 }).Where(t =>
                                               t.Customerservice.Title.StartsWith(customerServiceData.Search) ||
                                               t.Customerservice.JobNumber.StartsWith(customerServiceData.Search)).ToList();
Pact Construction

Converta LINQ para SQL Query Online

_dbContext.ClaimsReferrals.Where(x =>
            (referTo != 0 ? x.ReferTo == referTo : true) &&
            (!string.IsNullOrEmpty(refOwner) ? x.ReferralOwner == Guid.Parse(refOwner) : true) &&
            (referrerTeamId != 0 ? x.ReferrerTeamId != 0 && x.ReferrerTeamId == referrerTeamId : true) &&
            (!includeCompleted ? x.ReferralStatusId != Convert.ToInt16(Enum.ReferralStatus.Accepted) &&
            x.ReferralStatusId != Convert.ToInt16(Enum.ReferralStatus.Rejected) : true) &&
            ((isUrgentChecked || miFilter=="urgent") ? x.IsUrgent == true : true) &&
            (isOverdueChecked ? DateTime.Now > x.DueDate : true) &&
            ( draft_status!=0 ? x.ReferralStatusId != Convert.ToInt16(Enum.ReferralStatus.Draft) : true) &&
            (!string.IsNullOrEmpty(claimReference) ? !string.IsNullOrEmpty(x.ClaimReference) && x.ClaimReference.ToLower().Replace(" ",string.Empty) == claimReference.ToLower().Replace(" ",string.Empty) : true) &&
            (!string.IsNullOrEmpty(referralOwner) ? x.ReferralOwner != null && x.ReferralOwner == Guid.Parse(referralOwner) : true) &&
            x.IsActive == true && x.IsDeleted == false) .ToList();

            var referralList =(from referrals in data.OrderByDescending(x=>x.ModifiedOn>x.CreatedOn? x.ModifiedOn:x.CreatedOn).Skip(page != 1 ? (page - 1) * limit : 0)
            .Take(limit).ToList()
            join referrerTeam in _dbContext.ReferrerTeams.Where(x=>x.IsActive==true && x.IsDeleted==false).ToList() on referrals.ReferrerTeamId equals referrerTeam.Id into teams
                            from subteams in teams.DefaultIfEmpty()
                            join businessarea in _dbContext.BusinessAreas.Where(x=>x.IsActive==true && x.IsDeleted==false).ToList() on referrals.BusinessAreaId equals businessarea.Id into business
                            from subbusiness in business.DefaultIfEmpty()
                            join status in _dbContext.ReferralStatuses on referrals.ReferralStatusId equals status.Id into referralstatus
                            from substatus in referralstatus.DefaultIfEmpty()
                            join ciuteams in _dbContext.Ciuteams.Where(x=>x.IsActive==true && x.IsDeleted==false).ToList() on referrals.ReferTo equals ciuteams.Id into referralciuteam
                            from subciuteam in referralciuteam.DefaultIfEmpty()
                            join refteams in _dbContext.ReferrerTeams.Where(x=>x.IsActive==true && x.IsDeleted==false).ToList() on referrals.ReferrerTeamId equals refteams.Id into referrerteam
                            from subteam in referrerteam.DefaultIfEmpty()
                            join owner in _dbContext.Users.Where(x=>x.IsActive==true && x.IsDeleted==false).ToList() on referrals.ReferralOwner equals Guid.Parse(owner.Id) into intelowner
                            from refowner in intelowner.DefaultIfEmpty()
                            select new Referral
                            {
                                Id = referrals.Id.ToString(),
                                ClaimReference = referrals.ClaimReference,
                                CreatedDate = referrals.CreatedOn != null ? referrals.CreatedOn.ToString("yyyy-MM-dd") : null,
                                IsUrgent = referrals.IsUrgent != null ? (bool)referrals.IsUrgent ? "Yes" : "No" : "No",
                                UrgencyReason = referrals.UrgencyReason,
                                ReferralStatusId = substatus!=null?substatus.Name:null,
                                ReferTo = subciuteam != null ? subciuteam.Name : null,
                                ReferrerTeamId = subteam != null ? subteam.Name : null,
                                Reserve = referrals.Reserve != 0 ? referrals.Reserve.ToString() : null,
                                IsOverDue =  subbusiness !=null ? DateTime.Now > referrals.DueDate ? true :false : false,
                                DueDate=  referrals.DueDate!=null && subbusiness !=null ? referrals.DueDate.ToString("yyyy-MM-dd"):null,
                                ReferralOwner = refowner!=null? refowner.FirstName + " " + refowner.LastName :null
                            }).ToList();
Zealous Zebra

Conversor SQL para LINQ

select top 10 p.Nombre, p.Apellidos, (SELECT COUNT(*) FROM Personas ps WHERE PS.ParentCode LIKE '%' + CONVERT(VARCHAR, p.id) + '-%'   ) Total  
from personas p
ORDER BY Total desc
Smoggy Shrew

Respostas semelhantes a “Converta LINQ para SQL Query Online”

Perguntas semelhantes a “Converta LINQ para SQL Query Online”

Procure respostas de código populares por idioma

Procurar outros idiomas de código