Example #1
0
        public List <Measure> Get(MeasureSearchCriteria criteria)
        {
            var endDate = criteria.EndDate.AddDays(1);

            using (var context = new PowerUnitContext())
            {
                // składnia za pomocą wyrażeń lambda

                var measures = context.Measures
                               .Where(x => x.MeasureDate >= criteria.StartDate)
                               .Where(measure => measure.MeasureDate < endDate)
                               .OrderBy(measure => measure.MeasureDate)
                               .ToList();



                // składnia podobna do SQL

                //var measures = (
                //                   from measure in context.Measures
                //                   where measure.MeasureDate >= criteria.StartDate
                //                      && measure.MeasureDate < endDate
                //                   orderby measure.MeasureDate
                //                   select measure
                //                )
                //               .ToList();


                return(measures);
            }
        }
Example #2
0
        public void Add(ThreePhaseMeasure measure)
        {
            using (var context = new PowerUnitContext())
            {
                context.ThreePhaseMeasures.Add(measure);

                context.SaveChanges();
            }
        }
Example #3
0
        public void Add(Measure measure)
        {
            // Utworzenie instancji kontekstu
            using (var context = new PowerUnitContext())
            {
                // Dodanie do kontekstu
                context.Measures.Add(measure);

                // Zapis do bazy danych
                context.SaveChanges();
            }
        }