コード例 #1
0
        public void Context()
        {
            var newGrp = new UnitRenoGrp
            {
                hProp = 1,
                RenoGrpName = "when_saving_new",
                RenoGrpDesc = "Test description",
                LeadContractor = "Test Lead Contractor"
            };

            var newGroups = new List<UnitRenoGrp> { newGrp };

            Func<UnitRenoGrp, bool> expression =
                (existingGrp => existingGrp.RenoGrpName == newGrp.RenoGrpName &&
                    existingGrp.hProp == newGrp.hProp &&
                    existingGrp.RenoGrpDesc == newGrp.RenoGrpDesc &&
                    existingGrp.LeadContractor == newGrp.LeadContractor &&
                    existingGrp.ArchiveFlag == newGrp.ArchiveFlag);

            _entities = new ConstructionEntities();

            //remove existing context before test run
            var existing = _entities.UnitRenoGrps.Where(expression).ToList();

            if (existing.Any())
            {
                existing.ForEach(rg =>
                {
                    _entities.UnitRenoGrps.Attach(rg);
                    _entities.UnitRenoGrps.Remove(rg);
                });

                _entities.SaveChanges();
            }

            _target = new UnitRenovationGroupRepository(_entities);
            _target.Save(newGroups);
            _result = _target.Retrieve(expression).ToList()[0];
        }
コード例 #2
0
 public void Context()
 {
     _entities = new ConstructionEntities();
     _target = new UnitRenovationGroupRepository(_entities);
     _results = _target.Retrieve(rg => rg.ArchiveFlag != true).ToList();
 }