Show Property of a second level entity in datagridview c #

0

Good afternoon, I'm filling a datagriview with a list whose entity is:

public class ECliente
{
    public int CLI_CODIGO { get; set; }
    public string CLI_NOMBRE { get; set; }
    public string CLI_RUC { get; set; }
    public string CLI_DIRECCION { get; set; }
    ...
    ...
    public int EJE_CODIGO_AM { get; set; }
    public int TP_CODIGO { get; set; }

    public ECiudad CIUDAD { get; set; }

}

and the entity ECcity is as follows

public class ECiudad
{
    public int CIU_CODIGO { get; set; }
    public string CIU_NOMBRE { get; set; }
    public string CIU_ESTADO { get; set; }
    public string CIU_RUBRO_CON { get; set; }
}

and in the business layer I have the filling of my list.

    public List<ECliente> GetListClientes(string Criterio)
    {
        List<ECliente> lista = new List<ECliente>();
        ....
        ....

}

In the form I have a toolStrip button whose event is:

    private void tsBuscar_Click(object sender, EventArgs e)
    {
         ...
        dgvLista.AutoGenerateColumns = true;
        dgvLista.DataSource = nCliente.GetListClientes(sb.ToString());
    }

and I filled the datagridview

I want the CIU_NOMBRE property value of the entity ECIUDAD to be displayed ??

Also, I can use EF6 with SQL Server 2000 Express Edition ????, since all entities are creating it manually ...

Thanks for your kind help and suggestions.

    
asked by Guivan 26.08.2017 в 01:33
source

1 answer

0

overwrite the .ToString () function in the secondary class by returning the property you want and you'll have it fixed.

It would be something like this:

public class ECiudad
{
    public int CIU_CODIGO { get; set; }
    public string CIU_NOMBRE { get; set; }
    public string CIU_ESTADO { get; set; }
    public string CIU_RUBRO_CON { get; set; }
    public override string ToString()
    {
        return CIU_NOMBRE;
    }
}
    
answered by 26.08.2017 / 01:59
source