public MeasureTermsRepository(QuantityDbContext c) : base(c, c?.MeasureTerms) { }
public UnitsRepository(QuantityDbContext c) : base(c, c.Units) { }
public MeasuresRepository(QuantityDbContext c) : base(c, c.Measures) { }
public SystemsOfUnitsRepository(QuantityDbContext c) : base(c, c?.SystemsOfUnits) { }
private static void AddUnitFactors(List <Core.Units.Data> units, string siSystemId, QuantityDbContext db) { foreach (var d in from d in units where !(Math.Abs(d.Factor) < double.Epsilon) let o = db.UnitFactors.FirstOrDefaultAsync( m => m.SystemOfUnitsId == siSystemId && m.UnitId == d.Id).GetAwaiter().GetResult() where o is null select d) { db.UnitFactors.Add( new UnitFactorData() { SystemOfUnitsId = siSystemId, UnitId = d.Id, Factor = d.Factor }); } }
public MeasuresRepository(QuantityDbContext c) { db = c; }
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 }); } }
public UnitFactorsRepository(QuantityDbContext c) : base(c, c?.UnitFactors) { }
public UnitTermsRepository(QuantityDbContext c) : base(c, c?.UnitTerms) { }
public static void Initialize(QuantityDbContext db) { initializeMeasures(db); initializeUnits(db); }