public SystemsOfUnitsRepository(QuantityDbContext c) : base(c, c?.SystemsOfUnits) { }
public MeasuresRepository(QuantityDbContext c) : base(c, c.Measures) { }
public UnitFactorsRepository(QuantityDbContext c) : base(c, c?.UnitFactors) { }
public static void Initialize(QuantityDbContext db) { InitializeMeasures(db); InitializeUnits(db); }
public MeasureTermsRepository(QuantityDbContext c) : base(c, c?.MeasureTerms) { }
public UnitTermsRepository(QuantityDbContext c) : base(c, c?.UnitTerms) { }
private static void addUnitFactors(List <Core.Units.Data> units, string siSystemId, QuantityDbContext db) { foreach (var d in units) { if (Math.Abs(d.Factor) < double.Epsilon) { continue; } var o = db.UnitFactors.FirstOrDefaultAsync( m => m.SystemOfUnitsId == siSystemId && m.UnitId == d.Id).GetAwaiter().GetResult(); if (!(o is null)) { continue; } db.UnitFactors.Add( new UnitFactorData() { SystemOfUnitsId = siSystemId, UnitId = d.Id, Factor = d.Factor }); } }
private static void initialize(Core.Units.Data measure, List <Core.Units.Data> units, QuantityDbContext db) { addMeasure(measure, db); addTerms(measure, db.MeasureTerms); addUnits(units, measure.Id, db); addTerms(units, db); addUnitFactors(units, SystemOfUnits.SiSystemId, db); db.SaveChanges(); }
private static void addUnits(IEnumerable <Core.Units.Data> units, string measureId, QuantityDbContext db) { foreach (var d in from d in units let o = getItem(db.Units, d.Id) where o is null select d) { db.Units.Add( new UnitData { MeasureId = measureId, Id = d.Id, Code = d.Code, Name = d.Name, Definition = d.Definition }); } }