Within initialisation of a large object that contains many different types of child object...
I have a function that returns a KeyValuePair<string, object>. I would like to call this when initialising a Dictionary<string, object>, something like this:
AdditionalProperties = new Dictionary<string,object>(ams.GetKVP(AvaloqTypes.Person.PersonDocm.CountryId))
This gives a compilation error that "cannot convert from KeyValuePair to IDictionary"
I can work-around this as follows:
AdditionalProperties = new Dictionary<string,object>()
{
{ ams.GetKVP(AvaloqTypes.Person.PersonDocm.DocmItem).Key,
ams.GetKVP(AvaloqTypes.Person.PersonDocm.DocmItem).Value
}
}
However, this means the GetKVP method is called twice.
Is there a better solution that doesn't involve changing the GetKVP method?