저는 SQL에 익숙하며 아직 linq에는 익숙하지 않습니다. 값에 따라 열을 그룹화하고 다른 열을 목록으로 그룹화하고 다른 열을 정적으로 만들려면 어떻게해야합니까? 예정적 그룹 및 그룹화 된 열로 그룹화
People | Businesses | StreetAddress
John | Store 1 | Hello Blvd.
John | Store 2 | Hello Blvd.
를 들어
는 두 사람에 의해 그룹에 & StreetAddress을 필요로 가정하면 표 1
from x in ctx.People
join ownership in ctx.Ownerships
on x.Id equals ownership.Owner_Id into ps
from ownership in ps.DefaultIfEmpty()
join Business in ctx.Businesses
on ownership.Business_Id equals Business.Id into ps2
from Business in ps2.DefaultIfEmpty()
select new PersonDTO
{
Id = x.Id,
Business = Business.Name,
StreetAddress = x.Addresses.FirstOrDefault().Line1
}
SQL 쿼리를 사용하면 불가능하다고 생각합니다. StoredProcedure를 사용해야합니다. – Raghu