【问题标题】:Linq query returning value from another classLinq 查询从另一个类返回值
【发布时间】:2011-04-28 16:40:50
【问题描述】:

关于 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

提前致谢。

【问题讨论】:

  • 有错误吗? Viewing 类是什么?

标签: vb.net linq-to-entities


【解决方案1】:

我怀疑不是,当编译器尝试将 'Viewing(pt.ProspectId).GetViewings().Columns(7).ToString()' 位转换为 SQL 时,它会变得非常混乱。您需要分两个阶段进行。

第一个 Linq-to-entity 选择首先返回 pt.ProspectId.ToList() 完好无损。然后使用结果做更多​​的 linq,linq-to-linq,如果你愿意,你可以使用 lambda 进行查找。

【讨论】:

  • 啊,就像我想的那样!想我还是会问的!
  • 如果我想知道另一种方式,那就是我如何让这种事情发挥作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-25
相关资源
最近更新 更多