最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

将整数列表连接到整数

SEO心得admin34浏览0评论
本文介绍了将整数列表连接到整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好

问题是我有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

发布评论

评论列表(0)

  1. 暂无评论