Note: agilityItemDetailDto.OwnershipRoles // it's custom collection
//Add Key and value into dictionary
Dictionary<string, string> OwnershipRoleHolders = new Dictionary<string, string>();
if (agilityItemDetailDto.OwnershipRoles != null)
{
OwnershipRoleHolders =
agilityItemDetailDto.OwnershipRoles.Select(
r =>
new
{
Key = r.OwnershipRoleSingleDisplayText,
Value = String.Join(";", r.RoleHolders.Select(h => h.Title).ToArray())
}).ToDictionary(d => d.Key, d => d.Value);
}
// string val2;
//get Value based on key . For eg -OwnershipRoleHolders.ContainsKey("<Pass key name>")
if (OwnershipRoleHolders.ContainsKey("Approver"))
{
string val1;
OwnershipRoleHolders.TryGetValue("Approver", out val1);
ApproverRoleTitle = val1;
}
//Add Key and value into dictionary
Dictionary<string, string> OwnershipRoleHolders = new Dictionary<string, string>();
if (agilityItemDetailDto.OwnershipRoles != null)
{
OwnershipRoleHolders =
agilityItemDetailDto.OwnershipRoles.Select(
r =>
new
{
Key = r.OwnershipRoleSingleDisplayText,
Value = String.Join(";", r.RoleHolders.Select(h => h.Title).ToArray())
}).ToDictionary(d => d.Key, d => d.Value);
}
// string val2;
//get Value based on key . For eg -OwnershipRoleHolders.ContainsKey("<Pass key name>")
if (OwnershipRoleHolders.ContainsKey("Approver"))
{
string val1;
OwnershipRoleHolders.TryGetValue("Approver", out val1);
ApproverRoleTitle = val1;
}