A Product can have multiple SubProducts. And multiple Customers/Leads can subscribe to multiple SubProducts
It is described as under
class NProduct
{
public string ProductID { get; set; }
public List<NSubProduct> SubProducts { get; set; }
}
class NSubProduct
{
public string NSubProductID { get; set; }
public string Color { get; set; }
public string NSubProductName { get; set; }
public List<NLead> NLeads { get; set; }
}
class NLead
{
public string NLeadID { get; set; }
public DateTime NCreatedDate { get; set; }
}
Sample data for population of the above data structure
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var dataSRC = SourceData();
}
private static NProduct SourceData()
{
NProduct objNProduct = new NProduct();
objNProduct.ProductID = "1";
objNProduct.SubProducts = GetSubProducts();
return objNProduct;
}
private static List<NSubProduct> GetSubProducts()
{
List<NSubProduct> lstSubProds = new List<NSubProduct>();
Enumerable
.Range(1, 4)
.ToList()
.ForEach(
i =>
lstSubProds.Add(
new NSubProduct
{
NSubProductID = "NSubProductID" + i.ToString()
, NSubProductName = "SubProduct" + i.ToString()
, NLeads = GetLeads(i)
}));
return lstSubProds;
}
private static List<NLead> GetLeads(int j)
{
List<NLead> lstLeads = new List<NLead>();
for(int i=0;i<5;i++)
{
lstLeads.Add(
new NLead
{
NLeadID = "NLeadID" + ((i%2==0)?i.ToString() : j.ToString())
,NCreatedDate = DateTime.Now.AddDays(j)
});
}
return lstLeads;
}
}
class NProduct
{
public string ProductID { get; set; }
public List<NSubProduct> SubProducts { get; set; }
}
class NSubProduct
{
public string NSubProductID { get; set; }
public string NSubProductName { get; set; }
public List<NLead> NLeads { get; set; }
}
class NLead
{
public string NLeadID { get; set; }
public DateTime NCreatedDate { get; set; }
}
}