I have a problem with Dapper. I have a list of a class Rubricathat contains a field valore. When I run the request with JOIN and determine the type of agenda, the field valoreremains set tonull
My two classes RubricaandTipoAgenda
public class Rubrica
{
public int id_rubrica { get; set; }
public string cod_anagrafica { get; set; }
public string descrizione_contatto { get; set; }
public TipoRubrica tipo { get; set; }
public string valore { get; set; }
}
public class TipoRubrica
{
public int id_tipo_rubrica { get; set; }
public string descrizione_tipo_rubrica { get; set; }
}
I created a function that returns me a list Agendaexecuting a JOIN with a tableanagrafico_tipo_rubrica
public List<Rubrica> GetAgendaAnagrafico(string codiceAnagrafico)
{
using (DatabaseConnection db = new DatabaseConnection())
{
const string query = @"SELECT * FROM anagrafico_rubrica JOIN anagrafico_tipo_rubrica ON tipo = id_tipo_rubrica WHERE cod_anagrafica = @anagrafico";
var parametri = new { anagrafico = codiceAnagrafico };
return db.con.Query<Rubrica, TipoRubrica, Rubrica>(query, (rubrica, tipo) => { rubrica.tipo = tipo; return rubrica; }, parametri, splitOn: "tipo").ToList();
}
}
Here you can see what the query returns

And here you see how in the int list Agendathe value valoreset tonull

source
share