I am facing issue while trying to query SQLCE
database in my Windows Phone Mango application.
I get exception when I execute
foreach (var item in myDataContext.MyTable.Select(item => item))
The column name is not valid. [ Node name (if any) = t0,Column name = version ]
Strangely, when I execute query based on any individual column, it works fine
foreach (var item in myDataContext.MyTable.Select(item => item.SomeColumn))
Any idea what could be wrong here?
I installed LINQ to SQL Debug Visualizer to find out what query exactly is being generated behind the scene and it was
{SELECT [t0].[version], [t0].[ID], [t0].[Volume], ... similarly rest of the columns
FROM [MyTable] AS [t0]
This was strange because I didn't had version column in my table (ever). I looked into my model and I found this column defined
[Column(IsVersion = true)]
private Binary version;
I removed column by commenting out these two lines and re-ran the app. Newly generated SQL didn't had any version
column and my query worked fine.
I am using SQLCEMangoCodeGenerator
for generating LINQ to SQL classes. I guess error is in this tool because of which it generated an extra column which I didn't have in my table