Sono confuso a causa della query che restituisce dati diversi per una sola colonna quando si utilizza una query SQL non elaborata da Entity Framework (vedere lo screenshot in basso).
Il risultato corretto è ovviamente quello che ottengo durante l'interrogazione del database direttamente da SQL Server.
Certamente, sto eseguendo esattamente la stessa query, sullo stesso database e sullo stesso server. E sto cercando le stesse colonne.
EDIT: Ecco la classe LigneFacture:
public class LigneFacture
{
[Required]
public string Entite { get; set; }
public decimal NumFacture { get; set; }
[Required]
[StringLength(2)]
public string TypeTransaction { get; set; }
[Required]
public DateTime DateFacture { get; set; }
[StringLength(10)]
public string CodeClient { get; set; }
[StringLength(100)]
public string NomClient { get; set; }
[Required]
[StringLength(10)]
public string CodeProduit { get; set; }
[StringLength(150)]
public string NomProduit { get; set; }
[StringLength(10)]
public string CodeLabo{ get; set; }
[StringLength(150)]
public string Laboratoire { get; set; }
[Required]
[StringLength(25)]
public string Numlot { get; set; }
public DateTime Peremption { get; set; }
public decimal Quantite { get; set; }
public decimal ValeurHt { get; set; }
public decimal ValeurRz { get; set; }
public decimal ValeurTva { get; set; }
public decimal PuAchat { get; set; }
public decimal PuPpa { get; set; }
public decimal PuDemi { get; set; }
public decimal PuCess { get; set; }
//This field is causing the problem (it's declared as int in the database as well)
public int Ligne { get; set; }
public string HreString { get; set; }
public int AnneeTransaction { get; set; }
public int MoisTransaction { get; set; }
public decimal TauxRemise { get; set; }
public string Zone { get; set; }
public int Colis { get; set; }
}
Il resto dei valori è esattamente lo stesso.
Come ha sottolineato Ivan Stoev, sembra essere correlata la chiave primaria dell'entità interrogata.
Due righe su tre hanno solo un valore di colonna diverso ma la stessa chiave primaria esatta, quindi sembra che il primo sia restituito due volte.