I am getting a cast error with Linq to a DataTable that was populated with Oracle.
bool isTrue开发者_C百科 = DataTable.AsEnumerable().Any
(x => x.Field<int>("MYNUMBERFIELD") == MYNUMBER);
In SQL this works fine as expected. In Oracle is fails with a cast error on the cast. In C# code the same thing happens when you do the following:
int myint = (int)VariableRetrievedFromOracleDB;
If you change it to int myint = Convert.ToInt32(VariableRetrievedFromOracleDB)
it works fine.
Any ideas how to handle this with the lambda?
bool isTrue =
DataTable.AsEnumerable()
.Any(x => Convert.ToInt32(x.Field("MYNUMBERFIELD")) == MYNUMBER);
精彩评论