In both of the statements I am trying to fetch the ID of Category which has the name as specified in the variable;
Both work fine. What is the difference and which one is better?
string name = "Progreammers";
var categoryID = from c in DataContext.Categories
where c.Name == name
select c.CategoryID;
var categoryID =
DataContext.Categories.Single(c => c.Name == name).CategoryID;
EDIT: There is only one Name(field) for every CategoryID(field) in the table.