Sasi Rekha

Sasi Rekha

  • NA
  • 507
  • 93.8k

Get Value from list of objects

Apr 13 2018 2:11 AM
List<AttributeNamesValues> Keyvalues = new List<AttributeNamesValues>();
AttributeNamesValues keyvalue = new AttributeNamesValues();
keyvalue.AName = "Gross Volume";
keyvalue.AValue = "as100";
Keyvalues.Add(keyvalue);
keyvalue.AName = "Clean Volume";
keyvalue.AValue = "as120";
Keyvalues.Add(keyvalue);
keyvalue.AName = "Clean Volume%";
keyvalue.AValue = "asclean";
Keyvalues.Add(keyvalue);
List<AttributeKeyValues> attributeNames = (from main in db.Attributes_Sub
where attribute_subid.Contains(main.Id)
select new AttributeKeyValues
{
MainName = main.Attributes_Relation.Select(x => x.Attributes_Main.AttributeName).FirstOrDefault().ToString(),
SubName = main.AttributeSubName,
Value= Keyvalues.Where(item => item.AName == main.AttributeSubName).Select(x1=>x1.AValue).FirstOrDefault().ToString()
}).ToList();
 
I am getting error at while getting Value please help me

Answers (2)