add below line and check what is the type you get as data type
var type = dt.Columns["branchid"].DataType;
you need to cast the column to above type. You say it as int in the database but in your dataset it could be one of below
Int16
Int32
Int64
SByte
Single
UInt16
UInt32
UInt64
Better you debug and confirm the data type.
as per your below comment
Quote:
column Datatype is bigint .
try with
Int64
IEnumerable<DataRow> query1 = query.Where(p => p.Field<Int64>("branchid") == 1);