It's been a while since I am trying to figure out what is causing a cast exception in this case. Following is my code.
var ratingTermDetails = dtRating.AsEnumerable()
.Where(data => data.Field<int>("RATINGID") == ratingId)
.FirstOrDefault();
dtRating is a datatable which gets populated from the database (oracle). The datatype of the column Ratingid is Integer in the database and the column is not nullable. The variable ratingId is an integer too.