public void Import(IEnumerable <NlpAnomalousIngredients> data) { using (var transaction = session.BeginTransaction()) { var d = data.ToArray(); foreach (var row in d) { var dbRow = new Models.NlpAnomalousIngredients { AnomalousIngredientId = row.AnomalousIngredientId, Name = row.Name, 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.AnomalousIngredientId); } Log.DebugFormat("Created {0} row(s) in NlpAnomalousIngredients", d.Count()); transaction.Commit(); session.Flush(); } }
public void Import(IEnumerable<NlpAnomalousIngredients> data) { using (var transaction = this.session.BeginTransaction()) { var nlpIngredientsesArray = data.ToArray(); foreach (var nlpIngredients in nlpIngredientsesArray) { var databaseNlpIngredients = new Models.NlpAnomalousIngredients { AnomalousIngredientId = nlpIngredients .AnomalousIngredientId, Name = nlpIngredients.Name, Ingredient = Models.Ingredients.FromId( nlpIngredients.IngredientId), WeightForm = nlpIngredients.WeightFormId .HasValue ? Models.IngredientForms .FromId( nlpIngredients .WeightFormId.Value) : null, VolumeForm = nlpIngredients.VolumeFormId .HasValue ? Models.IngredientForms .FromId( nlpIngredients .VolumeFormId.Value) : null, UnitForm = nlpIngredients.UnitFormId.HasValue ? Models.IngredientForms .FromId( nlpIngredients .UnitFormId.Value) : null }; this.session.Save(databaseNlpIngredients, nlpIngredients.AnomalousIngredientId); } this.Log.DebugFormat("Created {0} row(s) in NlpAnomalousIngredients", nlpIngredientsesArray.Count()); transaction.Commit(); this.session.Flush(); } }
public void Import(IEnumerable<NlpAnomalousIngredients> data) { using (var transaction = this.session.BeginTransaction()) { var d = data.ToArray(); foreach (var row in d) { var anomalousIngredients = new Models.NlpAnomalousIngredients { AnomalousIngredientId = row.AnomalousIngredientId, Name = row.Name, 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(anomalousIngredients, row.AnomalousIngredientId); } Log.DebugFormat("Created {0} row(s) in NlpAnomalousIngredients", d.Count()); transaction.Commit(); this.session.Flush(); } }