System.Generic.IEnumerable 集合的 ASP.Net LINQ to SQL 语法分组

发布于 2024-12-18 10:39:03 字数 602 浏览 2 评论 0原文

.Net 应用程序调用存储过程并返回存储为“结果”的集合。我希望能够按“CreatorLineOfBusinessID”对结果进行分组。它返回该字段以及其他几个字段。我想对“结果”数据集使用 LINQ 查询。提前致谢。

Dim result As IEnumerable(Of eRefer_Reports.uspReport_ReferralsSentBetweenLinesOfBusinessResult)

             strFromLOBID = " "
            Session("FromLineOfBusiness") = strFromLOBID
            strToLOBID = " "
            Session("ToLineOfBusiness") = strToLOBID

            result = repository.GetQueryResults(CDate(Me.txtStartDate.Text), CDate(Me.txtEndDate.Text), strFromLOBID, strToLOBID)
            BindGridView(result)          

.Net application calls Stored Procedure and returns collection which is stored as 'result.' I want to be able to group the results by 'CreatorLineOfBusinessID'. It returns that field along with several other fields. I would like to use a LINQ query on the 'result' data set. Thanks in advance.

Dim result As IEnumerable(Of eRefer_Reports.uspReport_ReferralsSentBetweenLinesOfBusinessResult)

             strFromLOBID = " "
            Session("FromLineOfBusiness") = strFromLOBID
            strToLOBID = " "
            Session("ToLineOfBusiness") = strToLOBID

            result = repository.GetQueryResults(CDate(Me.txtStartDate.Text), CDate(Me.txtEndDate.Text), strFromLOBID, strToLOBID)
            BindGridView(result)          

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

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

发布评论

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

评论(2

绮烟 2024-12-25 10:39:03

您对 Linq 分组进行过研究吗?请尝试此处的 101 个示例:http://msdn.microsoft.com/en-us/vstudio /bb688088

Dim orderGroups = From p In results Group p By Key = p.CreatorLineOfBusinessID Into Group _
Select CreatorBusinessId = Key, Referrals = Group

然后只需使用 Key 和属性 Referrals 迭代 orderGroups 即可IEnumerable

For Each lobBusiness in orderGroups

 ' Get the lobBusinessId : .CreatorBusinessId
 ' Get the IEnumerable results: .Referrals

Next

Have you done any research on Linq grouping? Try the 101 examples here: http://msdn.microsoft.com/en-us/vstudio/bb688088

Dim orderGroups = From p In results Group p By Key = p.CreatorLineOfBusinessID Into Group _
Select CreatorBusinessId = Key, Referrals = Group

Then just iterate over orderGroups using the Key and the property Referrals which will be an IEnumerable<eRefer_Reports.uspReport_ReferralsSentBetweenLinesOfBusinessResult>

For Each lobBusiness in orderGroups

 ' Get the lobBusinessId : .CreatorBusinessId
 ' Get the IEnumerable results: .Referrals

Next
白云悠悠 2024-12-25 10:39:03
Dim query = result.GroupBy(Function(x) x.ID).ToList()

应该按照您想要的方式对结果进行分组。

Dim query = result.GroupBy(Function(x) x.ID).ToList()

Should group the results the way you want.

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