How to check if two dictionaries are equal, or if at least a predefined key is the same
Addition:
this is what I have now, if I can do it cleaner, or if there is a better solution, I would love to know because this feels like crap
:
this is what I have now, if I can do it cleaner, or if there is a better solution, I would love to know because this feels like crap
if (data.TargetJson.Count == 0)
{
log.LogDebug("Adding all items to result['inject'] because target is empty");
result["inject"] = (from item in data.SourceJson select item).ToList();
}
else
{
log.LogDebug("Trying to add items that are to be injected");
result["inject"] = (from source in data.SourceJson
from target in data.TargetJson
where source[data.CommonIdentifier] != target[data.CommonIdentifier] && !source.DictEquals(target)
select source).ToList();
log.LogDebug("Trying to find items that are to be updated");
result["update"] = (from source in data.SourceJson
from target in data.TargetJson
where source[data.CommonIdentifier] == target[data.CommonIdentifier] && !source.DictEquals(target)
select target).ToList();
}if (data.TargetJson.Count == 0)
{
log.LogDebug("Adding all items to result['inject'] because target is empty");
result["inject"] = (from item in data.SourceJson select item).ToList();
}
else
{
log.LogDebug("Trying to add items that are to be injected");
result["inject"] = (from source in data.SourceJson
from target in data.TargetJson
where source[data.CommonIdentifier] != target[data.CommonIdentifier] && !source.DictEquals(target)
select source).ToList();
log.LogDebug("Trying to find items that are to be updated");
result["update"] = (from source in data.SourceJson
from target in data.TargetJson
where source[data.CommonIdentifier] == target[data.CommonIdentifier] && !source.DictEquals(target)
select target).ToList();
}