Mark Tabor

Mark Tabor

  • 573
  • 1.9k
  • 432.9k

exception data type

May 13 2023 9:01 AM

I have a simple methid in which I am getting records from view based on semester_ID like below 

public int Get_semesterCode(long semID)

{

var findCode=(from nn in db.SemesterView where vv.semesterId==semID.Tostring() select vv).firstOrDefault();

}

you can see my semID is long and the semesterId coming from view is having varchar(40) as type . I cannot change this long to string as it is requirement that the parameter semID must be long so how to compare , as work around i wrote a simple line like below

string semesid=semID.ToString() 

it have value collected and converted to string and semesid get the value but after that when the below code runs it gives exception 

var findCode=(from nn in db.SemesterView where vv.semesterId==semID.Tostring() select vv).firstOrDefault();

}


Answers (1)