本文介绍了在c#中合并两个数据集的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dataset1将有一系列奖项,而dataset2将是一个集合供应商。单一奖励可以与多个供应商相关。所以最终的合并数据集应该如下所示。



dataset1.record1 + dataset2.record1

dataset1.record1 + dataset2.record2

dataset1.record1 + dataset2.record3

dataset1.record1 + dataset2.record4

.....









dataset1.record1 + dataset2.recordN



dataset1.record2 + dataset2.record1

dataset1.record2 + dataset2.record2

dataset1.record2 + dataset2.record3

dataset1.record2 + dataset2.record4

.....









dataset1.record2 + dataset2.recordN等等...我用LINQ尝试了这个,但是它需要很长时间才能合并。与3500家供应商合并1000个奖项大约需要4分钟。还有其他方法可以改善性能吗?

dataset1 will have a collection of awards and the dataset2 will a collection vendors. single award can be related to multiple vendors. so the final merged dataset should looks like the following.

dataset1.record1+dataset2.record1
dataset1.record1+dataset2.record2
dataset1.record1+dataset2.record3
dataset1.record1+dataset2.record4
.....
.
.
.
.
dataset1.record1+dataset2.recordN

dataset1.record2+dataset2.record1
dataset1.record2+dataset2.record2
dataset1.record2+dataset2.record3
dataset1.record2+dataset2.record4
.....
.
.
.
.
dataset1.record2+dataset2.recordN and so on... I have tried this with LINQ it is working but it is taking long time to merge. It takes ~4 min to merge 1000 awards with 3500 vendors. Is there any other method to improve the performance?

推荐答案

SELECT <Field_List>
FROM Awards AS A <INNER|LEFT|RIGHT|CROSS> JOIN Vendors AS V ON A.PrimaryKey = V.ForeignKey



看看这里: []



2)使用 []

填写数据集后,您可以使用Linq查询从中获取数据。

请参阅: []


Have a look here: Visual Representation of SQL Joins[^]

2) using Linq[^]
When the datasets have been filled out, you can use Linq queries to fetch data from them.
See this: Method-Based Query Syntax Examples: Join (LINQ to DataSet)[^]


这篇关于在c#中合并两个数据集的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 08:07