L’errore in reportviewer e’ dovuto alla incompatibilita’ di tipi fra EF e lo stesso reportviewer: RPT non gestisce il tipo DateOnly.
La soluzione in EF e’ di aggiungere una proprieta’ non mappata nella classe parziale del modello di dati da usare per convertire ‘al volo’ il tipo DateOnly in DateTime:
/// <summary> /// Gets or sets the DateOnly data in database. /// </summary> /// <value> /// The dateonly value in database. /// </value> [Column("Data_Test")] public DateOnly? DataFromDb { get; set; } /// <summary> /// Gets the DateTime value for ReportViewer. /// </summary> /// <value> /// The data for the reportviewer. /// </value> [NotMapped] public DateTime? DataForRpt { get { if (DataTestDb.HasValue) { return DataFromDb.Value.ToDateTime(new TimeOnly(0, 0)); }; return null; } // set { DataFromDb = value?.ToDateOnly(); } }
A questo punto nel report il campo da usare punta a DataForRpt e non a DataFromDb.