__Correction, my fault, the database I was working against had a different scheme.__
I'm using "Add LINQ to SQL Datacontext".
When querying one table I get an InvalidCastException.
var test = from row in db.Batch select row;
foreach (var x in test)
Console.WriteLine(x);
It appears that a column of type float is the problem:
I can get data from other columns:
var test = from row in db.Batch select row.ColumnA; //(not float)
but when I query the column of type float the exception is thrown
var test = from row in db.Batch select row.ColumnB; //(float)
This is the stack trace of the InvalidCastException.
vid System.Data.SqlServerCe.SqlCeDataReader.GetDouble(Int32 ordinal)
vid Read_Double(ObjectMaterializer´1 )
vid System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader2.MoveNext()
I tried to modify the generated code, I changed ColumnB from this
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Cavity", DbType = "Float NOT NULL")]
to this
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Cavity", DbType = "Int NOT NULL")]
Comments: External: Generated coe and database schema did not match
I'm using "Add LINQ to SQL Datacontext".
When querying one table I get an InvalidCastException.
var test = from row in db.Batch select row;
foreach (var x in test)
Console.WriteLine(x);
It appears that a column of type float is the problem:
I can get data from other columns:
var test = from row in db.Batch select row.ColumnA; //(not float)
but when I query the column of type float the exception is thrown
var test = from row in db.Batch select row.ColumnB; //(float)
This is the stack trace of the InvalidCastException.
vid System.Data.SqlServerCe.SqlCeDataReader.GetDouble(Int32 ordinal)
vid Read_Double(ObjectMaterializer´1 )
vid System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader2.MoveNext()
I tried to modify the generated code, I changed ColumnB from this
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Cavity", DbType = "Float NOT NULL")]
to this
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "_Cavity", DbType = "Int NOT NULL")]
Comments: External: Generated coe and database schema did not match