Example #1
0
        public void Import(IEnumerable <IngredientForms> data)
        {
            using (var transaction = session.BeginTransaction())
            {
                var d = data.ToArray();
                foreach (var row in d)
                {
                    var dbRow = new Models.IngredientForms
                    {
                        IngredientFormId = row.IngredientFormId,
                        Ingredient       = Models.Ingredients.FromId(row.IngredientId),
                        ConvMultiplier   = row.ConvMultiplier,
                        FormAmount       = row.FormAmount,
                        UnitType         = row.UnitType,
                        UnitName         = row.UnitName,
                        FormUnit         = row.FormUnit,
                        FormDisplayName  = row.FormDisplayName
                    };

                    session.Save(dbRow, row.IngredientFormId);
                }

                Log.DebugFormat("Created {0} row(s) in IngredientForms", d.Count());
                transaction.Commit();
                session.Flush();
            }
        }
        public void Import(IEnumerable<IngredientForms> data)
        {
            using (var transaction = session.BeginTransaction())
             {
            var d = data.ToArray();
            foreach (var row in d)
            {
               var dbRow = new Models.IngredientForms
               {
                  IngredientFormId = row.IngredientFormId,
                  Ingredient = Models.Ingredients.FromId(row.IngredientId),
                  ConvMultiplier = row.ConvMultiplier,
                  FormAmount = row.FormAmount,
                  UnitType = row.UnitType,
                  UnitName = row.UnitName,
                  FormUnit = row.FormUnit,
                  FormDisplayName = row.FormDisplayName
               };

               session.Save(dbRow, row.IngredientFormId);
            }

            Log.DebugFormat("Created {0} row(s) in IngredientForms", d.Count());
            transaction.Commit();
            session.Flush();
             }
        }
        public void Import(IEnumerable<IngredientForms> data)
        {
            using (var transaction = this.session.BeginTransaction())
            {
                var ingredientFormsArray = data.ToArray();
                foreach (var ingredientForm in ingredientFormsArray)
                {
                    var databaseIngredientForm = new Models.IngredientForms
                                               {
                                                   IngredientFormId =
                                                       ingredientForm.IngredientFormId,
                                                   Ingredient =
                                                       Models.Ingredients.FromId(
                                                           ingredientForm.IngredientId),
                                                   ConvMultiplier = ingredientForm.ConvMultiplier,
                                                   FormAmount = ingredientForm.FormAmount,
                                                   UnitType = ingredientForm.UnitType,
                                                   UnitName = ingredientForm.UnitName,
                                                   FormUnit = ingredientForm.FormUnit,
                                                   FormDisplayName =
                                                       ingredientForm.FormDisplayName
                                               };

                    this.session.Save(databaseIngredientForm, ingredientForm.IngredientFormId);
                }

                this.Log.DebugFormat("Created {0} row(s) in IngredientForms", ingredientFormsArray.Count());
                transaction.Commit();
                this.session.Flush();
            }
        }