1
여러 테이블을 조인 한 LINQ 쿼리를 만들고 있습니다. 결과 세트에서 최소 및 최대 날짜를 결합하여 표시하는 열을 [예 : (20/3/2012 - 25/4/2012)] 표에서 광고하고 싶습니다.조인을 사용하는 LINQ 쿼리에서 Min 및 Max 함수를 사용합니까?
내가 날짜를 선택하고 싶은 곳에서 (많은 관계로 많은 관리 할 수있는 테이블) 테이블의 구조는 다음과 같습니다 :
var selectedResults=
from InvoiceSet in Invoices
join BookedAreaSet in BookedAreas on InvoiceSet.InvoiceID equals BookedAreaSet.InvoiceID
join AreaSet in Areas on BookedAreaSet.AreaID equals AreaSet.AreaID
join ContactSet in Contacts on InvoiceSet.ContactID equals ContactSet.ContactID
join Contacts_ObjectsSet in Contacts_Objects on ContactSet.ContactID equals Contacts_ObjectsSet.ContactID
join CompanySet in Companies on Contacts_ObjectsSet.ObjectReferenceID equals CompanySet.CompanyID
join BookedAreasSet in BookedAreas on InvoiceSet.InvoiceID equals BookedAreasSet.InvoiceID
where Contacts_ObjectsSet.ObjectReference=="Company"
select new {InvoiceSet.InvoiceNumber,InvoiceSet.Amount,InvoiceSet.TotalDiscount,InvoiceSet.GST,
InvoiceSet.PaymentDate,InvoiceSet.ShoppingCentreID,BookedAreasSet.BookedAreaID,AreaSet.Name,Paid=(InvoiceSet.PaymentDate==null ? "UnPaid":"Paid"),
licensee=(CompanySet.CompanyName))
};
:
여기
BookedAreaID int
AreaID int
LeasedDate datetime
InvoiceID int
내 LINQ 쿼리입니다
나는이 쿼리와 같은 것을 선택합니다 :이 컨디셔너에 두 번 참여하는 것처럼
DateRange=
(Min(BookedAreasSet.LeasedDate where BookedAreasSet.InvoiceID=InvoiceSet.InvoiceID)
+ "-" +
Max(BookedAreasSet.LeasedDate where BookedAreasSet.InvoiceID=InvoiceSet.InvoiceID)
이 작업을 수행 할 수 있습니다 http://stackoverflow.com/questions/2098375/subquery-in-linq-thats-in-the-select-statement-not-the-where-clause – speti43