public IEnumerable <IngredientBinding> LoadIngredientGraph()
        {
            if (ingredientdata != null)
            {
                return(ingredientdata);
            }

            var forms       = store.GetIndexedIngredientForms();
            var ingredients = store.GetIndexedIngredients();
            var graph       = (from ri in store.RecipeIngredients
                               join f in forms on ri.IngredientFormId equals f.Key
                               join i in ingredients on ri.IngredientId equals i.Key
                               where i.Key != ShoppingList.GUID_WATER
                               select IngredientBinding.Create(
                                   i.Key,
                                   ri.RecipeId,
                                   ri.Qty,
                                   ri.Unit,
                                   i.Value.ConversionType,
                                   i.Value.UnitWeight,
                                   f.Value.UnitType,
                                   f.Value.FormAmount,
                                   f.Value.FormUnit
                                   ));

            return(ingredientdata = graph);
        }
예제 #2
0
        public object TransformTuple(object[] tuple, string[] aliases)
        {
            return(IngredientBinding.Create
                   (
                       (Guid)tuple[0],     //R.IngredientId
                       (Guid)tuple[1],     //R.RecipeId
                       (Single?)tuple[2],  //R.Qty
                       (Units)tuple[3],    //R.Unit
                       (UnitType)tuple[4], //I.ConversionType
                       (int)tuple[5],      //I.UnitWeight

                       (Units)tuple[6],    //F.UnitType
                       (float)tuple[7],    //F.FormAmount
                       (Units)tuple[8]     //F.FormUnit
                   ));
        }