Only Bolivian Here
Only Bolivian Here

Reputation: 36743

Convert object to int in Linq Where clause

I'm trying to query a collection where a value of a DataColumn is equal to a number. Problem is, I can't convert an object to an int within a Linq query.

The error fires within the where clause. Any suggestions?

Is there a special syntax I'm not aware of?

var datos = _dttMasterViewTransaction.AsEnumerable().Where(r => r["JEID"] == FundsID).Select(r => new EntityJESummary()
{
    Test = r["test"]
}).ToList();

Upvotes: 0

Views: 2745

Answers (1)

Jamiec
Jamiec

Reputation: 136124

Special syntax? Does casting count?

_dttMasterViewTransaction.AsEnumerable().Where(r => (int)r["JEID"] == FundsID)

Upvotes: 3

Related Questions