Example #1
0
        public void Import(IEnumerable <Favorites> data)
        {
            using (var transaction = session.BeginTransaction())
            {
                var d = data.ToArray();
                foreach (var row in d)
                {
                    var dbRow = new Models.Favorites
                    {
                        FavoriteId = row.FavoriteId,
                        UserId     = row.UserId,
                        Recipe     = Models.Recipes.FromId(row.RecipeId),
                        Menu       =
                            row.MenuId.HasValue
                                                ? Models.Menus.FromId(row.MenuId.Value)
                                                : null
                    };

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

                Log.DebugFormat("Created {0} row(s) in Favorites", d.Count());
                transaction.Commit();
                session.Flush();
            }
        }
        public void Import(IEnumerable<Favorites> data)
        {
            using (var transaction = this.session.BeginTransaction())
            {
                var favoritesArray = data.ToArray();
                foreach (var favorites in favoritesArray)
                {
                    var databasefavorites = new Models.Favorites
                                          {
                                              FavoriteId = favorites.FavoriteId,
                                              UserId = favorites.UserId,
                                              Recipe = Models.Recipes.FromId(favorites.RecipeId),
                                              Menu =
                                                  favorites.MenuId.HasValue
                                                      ? Models.Menus.FromId(favorites.MenuId.Value)
                                                      : null
                                          };

                    this.session.Save(databasefavorites, databasefavorites.FavoriteId);
                }

                this.Log.DebugFormat("Created {0} row(s) in Favorites", favoritesArray.Count());
                transaction.Commit();
                this.session.Flush();
            }
        }
        public void Import(IEnumerable<Favorites> data)
        {
            using (var transaction = session.BeginTransaction())
             {
            var d = data.ToArray();
            foreach (var row in d)
            {
               var dbRow = new Models.Favorites
               {
                  FavoriteId = row.FavoriteId,
                  UserId = row.UserId,
                  Recipe = Models.Recipes.FromId(row.RecipeId),
                  Menu = row.MenuId.HasValue ? Models.Menus.FromId(row.MenuId.Value) : null
               };

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

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