There is a SQLite DB. It has a Studios table with the following structure:
CREATE TABLE Studios ( id INT PRIMARY KEY UNIQUE DEFAULT (0) NOT NULL, name STRING, filtered_name STRING, real BOOLEAN NOT NULL DEFAULT true, image STRING ); It is filled correctly and without errors from the List.
Interaction through linq2db. Entity classes are created according to the template that came with the library.
public partial class FiltersDB : LinqToDB.Data.DataConnection { public ITable<Studio> Studios { get { return this.GetTable<Studio>(); } } public FiltersDB() { InitDataContext(); } public FiltersDB(string configuration) : base(configuration) { InitDataContext(); } partial void InitDataContext(); } [Table("Studios")] public partial class Studio { [PrimaryKey, NotNull ] public int id { get; set; } // int [Column, Nullable] public string name { get; set; } // string(max) [Column, Nullable] public string filtered_name { get; set; } // string(max) [Column, NotNull ] public bool real { get; set; } // boolean [Column, Nullable] public string image { get; set; } // string(max) } public static partial class TableExtensions { public static Studio Find(this ITable<Studio> table, int id) { return table.FirstOrDefault(t => t.id == id); } } I try to get the value of the table by the following method:
public static List<ShikiApiLib.Studio> GetStudiosFromDB() { using (var db = new FiltersDB("Filters")) { var response = new List<ShikiApiLib.Studio>(); var table = db.Studios.Select(x => x); //(!)для дебага var table1 = table.ToList(); //(!)для дебага foreach (var studio in db.Studios.Select(x => x).ToList()) { response.Add(new ShikiApiLib.Studio() { id = studio.id, name = studio.name, filtered_name = studio.filtered_name, real = studio.real, image = studio.image }); } return response; } } on line with table1, a System.InvalidCastException: "Заданное приведение является недопустимым." error pops up System.InvalidCastException: "Заданное приведение является недопустимым."
And in the table the following is displayed:
UPD: If you delete from the table all the rows in which the image column is null , then the error does not appear = /
But this is not a solution, since I need these lines = /
UPD2: With this column, some kind of mysticism. For replacing null with an empty string or text like "no_image" before entering into a database table does not help. and deleting these lines eliminates the error again = /

realis a type in SQLite, possibly because as - Grundy[Column(Name = "real"), NotNull ] public bool isReal { get; set; } // boolean[Column(Name = "real"), NotNull ] public bool isReal { get; set; } // boolean[Column(Name = "real"), NotNull ] public bool isReal { get; set; } // booleanall the same thing = / - MrModestColumn(Name = "real")? - Grundy