I have a function that should return the Id of the element passed in parameters, like :
public static Int32 getIdByName(string name)
{
var query = from student in DataAccess.getInstance.StudentSet
where student.FirstName.Equals(name)
select student;
return toto;
}
I don't know how to convert the result toto
to an Int32 and return it !!
return DataAccess.getInstance.StudentSet.Last(s => s.FirstName == name).Id;
public static Int32 getIdByName(string name)
{
var query = from student in DataAccess.getInstance.StudentSet
where student.FirstName.Equals(name)
select student.Id;
return query.First();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.