I'm new on serializing Json files and i don't really know how to figure out my problem. My Db structure is made like this: A single Structure is related to multiple Units, and a single Unit to multiple Media, Details and Prices; So i have a structure like this:
List<Units> Units = Db.Units.Where(o => o.StructureId == StructureId).ToList();
foreach (Unit uni in Unita)
{
/* Getting units pics */
List<UnitMedia> Media = Db.UnitMedia.Where(o => o.UnitId == uni.UnitId).ToList();
/* Getting units details */
List<UnitDetails> Details = Db.UnitDetails.Where(o => o.UnitId == uni.UnitId).ToList();
/* Getting units prices */
List<UnitPrices> Prices = Db.UnitPrices.Where(o => o.UnitId == uni.UnitId).ToList();
}
Now what i want to do is to create a Json structure like:
Unit
{
SomeUnitAttributes
UnitMedia
{
UnitMediaDetails
}
UnitDetails
{
UnitDetailsDetails
}
UnitPrices
{
UnitPricesDetails
}
}
This must be the return of an API. Thank you all for your help