public void Import(IEnumerable <NlpDefaultPairings> data) { using (var transaction = session.BeginTransaction()) { var d = data.ToArray(); foreach (var row in d) { var dbRow = new Models.NlpDefaultPairings { DefaultPairingId = row.DefaultPairingId, Ingredient = Models.Ingredients.FromId(row.IngredientId), WeightForm = row.WeightFormId.HasValue ? Models.IngredientForms.FromId(row.WeightFormId.Value) : null, VolumeForm = row.VolumeFormId.HasValue ? Models.IngredientForms.FromId(row.VolumeFormId.Value) : null, UnitForm = row.UnitFormId.HasValue ? Models.IngredientForms.FromId(row.UnitFormId.Value) : null }; session.Save(dbRow, row.DefaultPairingId); } Log.DebugFormat("Created {0} row(s) in NlpDefaultPairings", d.Count()); transaction.Commit(); session.Flush(); } }
public void Import(IEnumerable<NlpDefaultPairings> data) { using (var transaction = this.session.BeginTransaction()) { var nlpDefaultPairingsArray = data.ToArray(); foreach (var nlpDefaultPairings in nlpDefaultPairingsArray) { var databaseNlpDefaultPairings = new Models.NlpDefaultPairings { DefaultPairingId = nlpDefaultPairings.DefaultPairingId, Ingredient = Models.Ingredients.FromId( nlpDefaultPairings.IngredientId), WeightForm = nlpDefaultPairings.WeightFormId .HasValue ? Models.IngredientForms.FromId( nlpDefaultPairings.WeightFormId.Value) : null, UnitForm = nlpDefaultPairings.UnitFormId .HasValue ? Models.IngredientForms.FromId( nlpDefaultPairings.UnitFormId.Value) : null }; databaseNlpDefaultPairings.VolumeForm = nlpDefaultPairings.VolumeFormId .HasValue ? Models.IngredientForms.FromId( nlpDefaultPairings.VolumeFormId.Value) : null; this.session.Save(databaseNlpDefaultPairings, nlpDefaultPairings.DefaultPairingId); } this.Log.DebugFormat("Created {0} row(s) in NlpDefaultPairings", nlpDefaultPairingsArray.Count()); transaction.Commit(); this.session.Flush(); } }
public void Import(IEnumerable<NlpDefaultPairings> data) { using (var transaction = this.session.BeginTransaction()) { var d = data.ToArray(); foreach (var row in d) { var defaultPairings = new Models.NlpDefaultPairings { DefaultPairingId = row.DefaultPairingId, Ingredient = Models.Ingredients.FromId(row.IngredientId), WeightForm = row.WeightFormId.HasValue ? Models.IngredientForms.FromId(row.WeightFormId.Value) : null, VolumeForm = row.VolumeFormId.HasValue ? Models.IngredientForms.FromId(row.VolumeFormId.Value) : null, UnitForm = row.UnitFormId.HasValue ? Models.IngredientForms.FromId(row.UnitFormId.Value) : null }; this.session.Save(defaultPairings, row.DefaultPairingId); } Log.DebugFormat("Created {0} row(s) in NlpDefaultPairings", d.Count()); transaction.Commit(); this.session.Flush(); } }