Linq 查询从另一个类返回值

发布于 2024-11-04 03:44:44 字数 1109 浏览 0 评论 0原文

只是一个关于 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

提前致谢。

Just a quick question about LINQ, I want to use a value from the returned dataset to lookup a value and return this. The line I am struggling with is .ViewingNotes = New Viewing(pt.ProspectId).GetViewings().Columns(7).ToString(). Is this possible?

    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

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欲拥i 2024-11-11 03:44:44

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

执行第一个 Linq-to-entity 选择,首先仅返回 pt.ProspectId,而 .ToList() 完好无损。然后使用结果执行更多 linq、linq-to-linq(如果您愿意),您可以在其中使用 lambda 进行查找。

I suspect not, when the compiler tries to convert the 'Viewing(pt.ProspectId).GetViewings().Columns(7).ToString()' bit to SQL it will get very confused. You would need to do it in 2 stages.

Do the first Linq-to-entity select first returning just pt.ProspectId, with the .ToList() intact. Then use the results to do some more linq, linq-to-linq if you like, where you can do the lookup using a lambda.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文