将整数列表连接到整数

编程入门 行业动态 更新时间:2024-10-20 17:21:19
本文介绍了将整数列表连接到整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好

问题是我有objectA,它是objectB的列表。现在,objectB有一个名为DataId的属性,它是一个整数。然后我有objectC,它是objectD的列表。 objectD有一个名为CompanyIds的属性,它是一个整数列表。

我需要的是使用以下内容将objectA加入objectC:

From obA 在 objectA 加入 obC In objectC On obA.DataId 等于 obC.CompanyIds _ 选择 新 objectB 使用 {.DataId = DataId})。ToList()

解决方案

您好Enocht,

将单个项目与项目列表进行比较时,我会使用Contains方法我建议进行以下更改。

来自 obA在 objectA加入 obC在 objectC On obC.CompanyIds.Contains(obA.DataId)_ 选择新 objectB使用 {。DataId = DataId})。ToList()

Contains方法用于确定元素是否在列表中。

我希望这会有所帮助。如果有任何问题或其他问题,请告诉我(我还没有机会对此进行测试,但理论上的声音是^^)。

Rob

Hi

The problem is that I have objectA, which is a list of objectB. Now objectB has a property called DataId, which is an integer. Then I have objectC, which is a list of objectD. And objectD has a property called CompanyIds, which is a list of integers.

What I need is to join objectA to objectC, using the following:

From obA In objectA Join obC In objectC On obA.DataId Equals obC.CompanyIds _ Select New objectB With {.DataId = DataId}).ToList()

解决方案

Hi Enocht,

When comparing a single item to a list of items I would use the Contains method. I would suggest the following alteration.

From obA In objectA Join obC In objectC On obC.CompanyIds.Contains(obA.DataId) _ Select New objectB With {.DataId = DataId}).ToList()

The Contains method is used for determining whether an element is within a list.

I hope this helps. Please let me know if there are any questions or other issues (I haven't had chance to test this yet but the theory's sound ^^).

Rob

更多推荐

将整数列表连接到整数

本文发布于:2023-11-30 09:40:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649530.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:整数   连接到   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!