Good evening, I’ve been trying to solve this problem for two days and haven’t received anything. I'm suspicious that this is a mistake, can someone help me? I get the following error message.
Unknown column "Distinct1.nCdSite" in the "where where" section
[MySqlException (0x80004005): Unknown column "Distinct1.nCdSite" in 'where clause'] MySql.Data.MySqlClient.MySqlStream.ReadPacket () +501 MySql.Data.MySqlClient.NativeDriver.GetResult & GetDesult +450 MySql.Data.MySqlClient.Driver.NextResult (Int32 statementId, Boolean force) +136 MySql.Data.MySqlClient.MySqlDataReader.NextResult () +1269 MySql.Data.MySqlClient.MySqlcome Data.Entity.EFMySqlCommand.ExecuteDbDataReader (CommandBehavior behavior) +22.,.
I have the following code:
Model:
[Table("pagina")] public class pagina { [Key] public long nCdPagina { get; set; } public long nCdVisitante { get; set; } public string sDsUrlReferencia { get; set; } public string sDsPalavraChave { get; set; } public string sDsTitulo { get; set; } [ForeignKey("nCdVisitante")] public visitante visitante { get; set; } } public class retorno { public long Key { get; set; } public int Online { get; set; } } [Table("site")] public class site { [Key] public long nCdSite { get; set; } public string sDsTitulo { get; set; } public string sDsUrl { get; set; } public DateTime tDtCadastro { get; set; } } [Table("visitante")] public class visitante { [Key] public long nCdVisitante { get; set; } public long nCdSite { get; set; } public string sDsIp { get; set; } public DateTime tDtCadastro { get; set; } public DateTime tDtAtualizacao { get; set; } [ForeignKey("nCdSite")] public site site { get; set; } }
Query:
return (from pag in this.context.pagina.Include("visitante").Include("site") group pag by pag.visitante.nCdSite into g select new retorno { Key = g.Key, Online = g.Select(e => e.visitante.sDsIp).Distinct().Count() }).ToList<retorno>();
The problem only occurs when placing Distinct() . Count() , not to mention work.
source share