Hi Sir,
There is a collection of list when i try to read then by default first row only read and access.
There may be multiple collections i want to loop that and get each of the id and name from collection.
How do i read and access all collection through loop.
Line number 121 in Image you can see there is a 2 item and may be that list contains 10 items.
So want to loop that item and read all value in line 134,135.
Please help in this.
Ampf.Motp.RefData.Services.ReferenceDataS ervice<TModel, 1)
{
if (property.PropertyType.ToString().Contains("ICollection"))
{
var item = property.GetValue(model);
if (item is ICollection)
{
var Count = ((ICollection)item).Count;
var KeyValue = (item as IEnumerable).Cast<object>().FirstOrDefault();
var KeyName = KeyValue.GetType().GetProperties().FirstOrDefault(x => x.Name == "Key");
var datasetname = KeyValue.GetType().Name;
var Keyindex = KeyName.GetValue(KeyValue);
var audititems = new ReferenceDatdAuditEntryDTO
{
Data = JsonConvert.SerializeObject(model, Formatting.Intented, new JsonSerializereSetting()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
}),
AuditDatetime = DateTime.Now,
ID = KeyIndex.ToString(),
ReferenceDatdAuditEntryId = Keyindex.ToString()
}
}
}
}