tags:

views:

65

answers:

2

I am new to SubSonic so please be gentle :) I am getting "Specified cast is not valid" when performing a save on my object using the SimpleRepository. Unfortunately I have no idea how to track down what is causing the exception.

Any help would be much appreciated.

+1  A: 

Is this specific to SubSonic? Do you know if you would get the same exception without using SubSonic? Typically, this exception means that somewhere in your code you are probably trying to cast a type that your database does not support.

For example with a column named ID, in C#/linq if you were to do something like

where COLUMN == (int)id

If the ID column was expecting a string, I believe that would cause "Specified cast is not valid" exception.

Mike Munroe
A: 

My mistake it turns out. I was trying to cast the result of the repo.Add method to an int as I assumed it was passing me back the id of the saved object.

ProNotion