字典与不同关键结构的匹配

时间:2014-04-18 16:46:14

标签: linq dictionary collections tuples

使用.NET 4.5.1,

var largeset = 
    new ConcurrentDictionary<Tuple<DateTime?, long?, long?>, MyClass>();
// 300,000 objects in this
largeset.TryAdd(
    new Tuple<DateTime?, long?, long?>(
        myclassobj.Date, myclassobj.Id1, myclassobj.Id2), myclassobj); 

var inputbits = new Dictionary<Tuple<long?, long?>, MyClass>();
// 10,000 objects in this
inputbits.Add(new Tuple<long?, long?>(newitem.Id1, newitem.Id2), newitem); 

inputbits具有与largeset不同的结构,inputbits在其Tuple键中缺少Date。

仅当largeset没有相同的Id1和Id2值时,将inputbits中的项添加到largeset的正确方法是什么?

大集和输入位之间会有很多匹配,我希望大约有10%没有匹配,我需要将它们添加到大集,并为Date设置空值。

数据源是一个报告转储,它采用日期加父ID和子ID的组合来唯一地分隔行。

0 个答案:

没有答案