This question is locked. New answers and comments are not allowed.
I'm trying to setup a query that just needs to check whether an item exists in the database. So I tried:
using (FluentModel db = new FluentModel())
{
string sql = "select count(AccountId) from Account where Account = @Account";
OAParameter param = new OAParameter();
param.ParameterName = "Account";
param.DbType = System.Data.DbType.String;
param.Value = AccountAlphaNum;
int result = db.ExecuteScalar<int>(sql, param);
if (result > 0)
{
exists = true;
}
}
But this results in "System.InvalidCastException: Specified cast is not valid."
Is there anything obvious that I'm missing here? Thanks!