I am having issues with a Linq query when it runs I receive the error Object reference not set to an instance of an object.
var RestaurantName = (from r in objCtx.Restaurants
where r.id == item.restaurantid
select r).SingleOrDefault<Restaurant>().Name;
I then changed the query to
var RestaurantName = (from r in objCtx.Restaurants
where r.id == item.restaurantid
select r).Single<Restaurant>().Name;
But I received the error Sequence contains no elements
. I checked the variable and it was returning a restaurant name. But I don't understand why I am receiving these errors.