http://www.codeguru.com/columns/vb/article.php/c15057__1/Implementing-a-Left-Join-with-LINQ.htm
Dim sSearch As String = "%" & tbSearch.Text.Trim & "%"
qMoulds = qMoulds.Where(
Function(m) Linq.SqlClient.SqlMethods.Like(m.MouldNo, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.MaterialCode, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.ProductDrg, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.Description, sSearch) Or
Linq.SqlClient.
SqlMethods.Like(m.ComponentCode, sSearch))
End If
Dim qMouldIds = From m In qMoulds
Select m.MouldNo
Distinct
Dim qCurrMoulds = From m In oDB.TTSMoulds
Join l In oDB.TTSLocations On m.LocationID Equals l.ID
Join s In oDB.TTSStores On l.StoreID Equals s.ID
Select m.MouldID, l.Location, s.StoreName
Dim qMouldInfo = From c In qMouldIds
Group Join m In qCurrMoulds On c Equals m.MouldID Into mgroup = Group
From cm In mgroup.DefaultIfEmpty()
Order By c
Select New MouldInfo With {
.MouldNo = c,
.Location = cm.Location,
.StoreName = cm.StoreName
}
Komentarų nėra:
Rašyti komentarą