关于LINQ的一个简单问题,我想使用返回数据集中的值来查找值并返回它。我正在努力的路线是.ViewingNotes = New Viewing(pt.ProspectId).GetViewings()。Columns(7).ToString()。这可能吗?
With BusinessLayerObjectManager.Context
Return (From p As [Property] In .PropertySet
Join pt As Prospect In .Prospects On pt.Property.propertyID Equals p.propertyID
Where (p.Development.DevelopmentID = devId)
Select New DevelopmentList With {
.Apartment = p.propertyApartment + " " + p.Development.Name,
.PropertyId = p.propertyID,
.Client = pt.Client.clientFirstname + " " + pt.Client.clientLastname,
.ClientId = pt.Client.ClientID,
.ProspectiveDate = pt.prospectiveDate,
.ProspectiveStatus = pt.prospectiveStatus,
.Agent = pt.Client.userID,
.ViewingNotes = New Viewing(pt.ProspectId).GetViewings().Columns(7).ToString(),
.PropertyStatus = ""
}).ToList()
End With
提前致谢。
答案 0 :(得分:0)
我怀疑不是,当编译器试图将'Viewing(pt.ProspectId).GetViewings()。Columns(7).ToString()'位转换为SQL时,它会变得非常困惑。您需要分两个阶段完成。
第一个Linq-to-entity选择首先返回pt.ProspectId
,.ToList()
完好无损。然后使用结果再做一些linq,linq-to-linq,如果你愿意,可以使用lambda进行查找。