示例#1
0
 public SystemsOfUnitsRepository(QuantityDbContext c) : base(c, c?.SystemsOfUnits)
 {
 }
示例#2
0
 public MeasuresRepository(QuantityDbContext c) : base(c, c.Measures)
 {
 }
示例#3
0
 public UnitFactorsRepository(QuantityDbContext c) : base(c, c?.UnitFactors)
 {
 }
 public static void Initialize(QuantityDbContext db)
 {
     InitializeMeasures(db);
     InitializeUnits(db);
 }
示例#5
0
 public MeasureTermsRepository(QuantityDbContext c) : base(c, c?.MeasureTerms)
 {
 }
示例#6
0
 public UnitTermsRepository(QuantityDbContext c) : base(c, c?.UnitTerms)
 {
 }
示例#7
0
        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
                });
            }
        }
示例#8
0
 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();
 }
示例#9
0
 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
         });
     }
 }