For example I am searching for a specific persons ID and I want to store that ID to a local variable or instance variable. How do I retrieve Query results and stores them in a int Variable with LINQ to SQL? Assuming we have this query
from user in dbo.DoctorsName
where doctorsName = "Foo Bar"
select DOC_ID;
You can use FirstOrDefault()
like this:
var results = from user in dbo.DoctorsName
where user.doctorsName == "Foo Bar"
select user;
string personName = results.FirstOrDefault().Name;