Ejemplo n.º 1
0
        public void AssignOrder(Order order)
        {
            Orders.Add(order);

            foreach (Recipe recipe in order.Recipes)
            {
                if (!Cooks.Any())
                {
                    return;
                }

                Cook minimumRecipeCook = null;
                foreach (Cook cook in Cooks)
                {
                    if (minimumRecipeCook == null)
                    {
                        minimumRecipeCook = cook;
                    }
                    else
                    {
                        if (cook.Recipes.Count < minimumRecipeCook.Recipes.Count)
                        {
                            minimumRecipeCook = cook;
                        }
                    }
                }

                if (minimumRecipeCook != null)
                {
                    minimumRecipeCook.Recipes.Add(recipe);
                    Console.WriteLine("A recipe has been assigned to the cook : {0}", minimumRecipeCook.GetHashCode().ToString());
                }
            }
        }
 public void Any_OnTopLevel_WithoutPredicate()
 {
     CheckQuery(
         () => Cooks.Any(),
         "SELECT CONVERT(BIT, CASE WHEN EXISTS((SELECT [t0].[ID] FROM [CookTable] AS [t0])) THEN 1 ELSE 0 END) AS [value]",
         row => (object)row.GetValue <bool> (new ColumnID("value", 0)));
 }
 public void Any_OnTopLevel_WithPredicate()
 {
     CheckQuery(
         () => Cooks.Any(c => c.FirstName == "Hugo"),
         "SELECT CONVERT(BIT, CASE WHEN EXISTS((SELECT [t0].[ID] FROM [CookTable] AS [t0] WHERE ([t0].[FirstName] = @1))) "
         + "THEN 1 ELSE 0 END) AS [value]",
         row => (object)row.GetValue <bool> (new ColumnID("value", 0)),
         new CommandParameter("@1", "Hugo"));
 }