Quick question... I had some strange problems with ordering of ingredients in a recipe app that I'm building. The first item defined was always displaying last. It's a bit of a hack at the moment, but I'm sorting by ingredient ID, an auto-increment integer field.
Here's how I was saving when the problem was occurring...
RecipeIngredientCollection tempIngs = tempIngredients;
foreach (RecipeIngredientEntity ing in tempIngs)
{
RecipeIngredientEntity newIng = new RecipeIngredientEntity();
newIng.RecipeID = recipe.ID;
newIng.Ingredient = ing.Ingredient;
newIng.Quantity = ing.Quantity;
newIng.Measurement = ing.Measurement;
newIng.Note = ing.Note;
recipe.Ingredients.Add(newIng)
}
recipe.Ingredients.SaveMulti(true);
And here's how I'm saving now. Not quite as efficient or safe, but I'm not sure what else to try.
RecipeIngredientCollection tempIngs = tempIngredients;
foreach (RecipeIngredientEntity ing in tempIngs)
{
RecipeIngredientEntity newIng = new RecipeIngredientEntity();
newIng.RecipeID = recipe.ID;
newIng.Ingredient = ing.Ingredient;
newIng.Quantity = ing.Quantity;
newIng.Measurement = ing.Measurement;
newIng.Note = ing.Note;
newIng.Save();
}
Can anyone explain what was happening previously? Thanks all!