I have a datable from SP which has Category, Subcategory and Message. For one Category there is multiple subcategories and for one subcategory there is multiple message texts. So in Get services I need to send these category in array format in an object.
CategoryName | SubCategoryName | MessageText |
---|---|---|
Framing | Face Covered | Child’s face can not be clearly seen |
Framing | Face Covered | food detected |
Lighting | Incorrect lighting | Poor lighting detected |
Lighting | Incorrect lighting | Not recommended |
Lighting | Too dark | Sun behind the Child detected |
I’m using asp.net core 8 application. I have two model class
So in existing service I need to add these response details, so created one private method in DAL Layer.
I’m trying to add groupby for categoryname and subactegoryname but I’m getting some error**”Cannot implicitly convert type ‘System.Collections.Generic.IEnumerable<System.Collections.Generic.List<Char>>’ to ‘String'”** .
The Code which I written;
private List<ARMCategory> CategoryDetailsCUP(DataSet mediaReviewDetails)
{
List<ARMCategory> ARMCategory = new List<ARMCategory>();
if (mediaReviewDetails != null)
{
foreach (DataRow dataRow in mediaReviewDetails.Tables[2].Rows)
{
List<ARMSubCategory> results2 = ARMCategory
.GroupBy(p => new { p.CategoryName, p.SubCategoryNames },
(k, c) => new ARMCategory()
{
CategoryName = k.CategoryName,
SubCategoryNames = c.Select(cs => cs.SubCategoryNames.ToList()),
MessageTexts = c.Select(cs => cs.MessageTexts.ToList())
}
).ToList();
return ARMCategory;
}
}
//return result2;
}
For example the output I needed,
For Category Framing we have a Facecovered Subcategory so it needs to map under category framing and for Subcategory facecovered we have multiple MessageText so these texts should map under respective subcategory. Like these for each Category need to map respective subcategory and message text.
So need code in C#
Sindhu C L is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.