I'm implementing asp.net core project and I have a line of code like following:
var myAPIApplicantId = (from x in _context.Apiapplicant
where x.ApiRequestNo == apiapplicantviewmodel.apiApplicantvm.ApiRequestNo
select new { x.Id }).First();
After running the project I understand myAPIApplicantId contains { Id = 1148 }.
In another line of code, I have the following code:
int IntAPIApplicantID = Convert.ToInt32(myAPIApplicantId);
But it throws an error for type casting. Now I want to know how cant I get 1148 value to convert to int?
myAPIApplicantIdis an interger, why convert to an int. Even if it is a string, the line of codeConvert.ToInt32must work. If it is an object, the access the Id properly withmyAPIApplicantId.Id