See the example below;
This is a webforms
application, but you only need to understand the part of classes and what you have inside the Page_Load
method.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
var addlista = new List<PropostaAgente>();
var lista1 = new PropostaAgente()
{
Campo1 = "Campo1",
Campo2 = "Campo2",
};
addlista.Add(lista1);
var Promotora = new LojaPromotoraInfo
{
CodGerente = "CodGerente",
CodLojaPromotora = "CodLojaPromotora",
Agente = addlista,
};
var teste = Promotora;
}
}
public class LojaPromotoraInfo
{
public List<PropostaAgente> Agente { get; internal set; }
public string CodGerente { get; internal set; }
public string CodLojaPromotora { get; internal set; }
}
public class PropostaAgente
{
public string Campo1 { get; internal set; }
public string Campo2 { get; internal set; }
}
}
You can change addlista
by a method that returns this list or only informs the list if you already have it.