score:0

Accepted answer
dictionary<string, list<string>> dictionary_1 = new dictionary<string, list<string>> { };
dictionary<string, list<string>> dictionary_2 = new dictionary<string, list<string>> { };

// fill those dictionaries...

// check for non existing things in dictionary 2 but existing in 1
foreach (keyvaluepair<string, list<string>> _element in dictionary_1)
{
    list<string> _valuesfrom2;
    // check if table exist
    if (dictionary_2.trygetvalue(_element.key, out _valuesfrom2))
    {
        //check if column exist
        foreach (string _value in _element.value)
        {
            if (!_valuesfrom2.contains(_value))
            {
                console.writeline($"dictionary 2, table {_element.key} does not contain {_value}");
            }
        }
    }
    else
    {
        console.writeline($"dictionnary 2 does not contain : {_element.key}");
    }
}

score:0

public static class joinextensions
{
    public static ienumerable<tresult> fulloutergroupjoin<tleft, tright, tkey, tresult>(
        this ienumerable<tleft> leftseq,
        ienumerable<tright> rightseq,
        func<tleft, tkey> keyselectorleft,
        func<tright, tkey> keyselectorright,
        func<ienumerable<tleft>, ienumerable<tright>, tkey, tresult> projectionselector,
        iequalitycomparer<tkey> comparer = null)
    {
        comparer = comparer ?? equalitycomparer<tkey>.default;
        var leftlookup = leftseq.tolookup(keyselectorleft, comparer);
        var rightlookup = rightseq.tolookup(keyselectorright, comparer);
        var keys = new hashset<tkey>(leftlookup.select(g => g.key), comparer);
        keys.unionwith(rightlookup.select(g => g.key));
        var join = keys
            .select(key => projectionselector(leftlookup[key], rightlookup[key], key));
        return join;
    }

    public static ienumerable<tresult> fullouterjoin<tleft, tright, tkey, tresult>(
        this ienumerable<tleft> leftseq,
        ienumerable<tright> rightseq,
        func<tleft, tkey> keyselectorleft,
        func<tright, tkey> keyselectorright,
        func<tleft, tright, tkey, tresult> projectionselector,
        tleft defaultleft = default(tleft),
        tright defaultright = default(tright),
        iequalitycomparer<tkey> comparer = null)
    {
        comparer = comparer ?? equalitycomparer<tkey>.default;
        var leftlookup = leftseq.tolookup(keyselectorleft, comparer);
        var rightlookup = rightseq.tolookup(keyselectorright, comparer);

        var keys = new hashset<tkey>(leftlookup.select(g => g.key), comparer);
        keys.unionwith(rightlookup.select(g => g.key));

        var join = keys
            .selectmany(
                key => leftlookup[key].defaultifempty(defaultleft),
                (key, leftitem) => new { key, leftitem })
            .selectmany(
                leftitemandkey => 
                    rightlookup[leftitemandkey.key]
                        .defaultifempty(defaultright),
                (leftitemandkey, rightitem) =>
                    projectionselector(
                        leftitemandkey.leftitem, 
                        rightitem, 
                        leftitemandkey.key));

        return join;
    }

    public static ienumerable<tresult> fullouterjoin<tleft, tright, tkey, tresult>(
        this ienumerable<tleft> leftseq,
        ienumerable<tright> rightseq,
        func<tleft, tkey> keyselectorleft,
        func<tright, tkey> keyselectorright,
        func<tleft, tright, tresult> projectionselector,
        tleft defaultleft = default(tleft),
        tright defaultright = default(tright),
        iequalitycomparer<tkey> comparer = null)
    {
        return leftseq
            .fullouterjoin(
                rightseq,
                keyselectorleft,
                keyselectorright,
                (leftitem, rightitem, _) => projectionselector(leftitem, rightitem),
                defaultleft,
                defaultright,
                comparer);
    }
}

Related Query

More Query from same tag