I have a dictionary with restaurants and a type of restaurant like this:
Dictionary<Restaurant, string> restaurants = new Dictionary<Restaurant, string>();
randomRestaurants.Add(restaurants.GroupBy(x => x.string).//Randomly pick an entry per grouping and add it to list//
List<Restaurant> randomRestaurants = new List<Restaurant>();
First idea (for any usage of this list) would be to order your data source into a more sensible format, that is, a key value structure wherein the key type is the thing that identifies a subset of restaurants (string), and the value is a list of the Restaurants within it.
You can do this using code similar to the following:
var sensibleDict = sillyDict .GroupBy(kv => kv.Value) .ToDictionary( m => m.Key, m => m.Select(kv => kv.Key).ToList());
Now, we can simply randomise the result and take the first after randomisation to convert that into a Key => Single Value item.
var randomDict = sillyDict .GroupBy(kv => kv.Value) .ToDictionary( m => m.Key, m => m.Select(kv => kv.Key) .OrderBy(k => Guid.NewGuid()) .Take(1) .First());
This will get you a
Dictionary<string, Restaurant> wherein the first string is the type of food (ie. Italian, Sushi) and the second is the random
Note: As I said in my comment, this isn't the most efficient way to order a list if your dataset gets large. For better methods of shuffling a list, take a look at this answer - Randomise a List.