Пример #1
0
        public void TestMethod1()
        {
            using (DbEntities context = new DbEntities())
            {
                TopLevelObject top = new TopLevelObject();
                top.PopulateTest();
                context.TopLevelObject.Add(top);

                IEnumerable<DbEntityValidationResult> errors = context.GetValidationErrors();

                context.SaveChanges();

                IEnumerable<SecondLevelObjectBase> objects =
                    (from t in context.TopLevelObject
                     join s in context.SecondLevelObject
                     on t.TopLevelObjectId equals s.Parent.TopLevelObjectId
                     where t.TopLevelObjectId == top.TopLevelObjectId
                     select s).ToList();

                Assert.AreEqual(objects.Count(), 3);

                Assert.AreEqual(objects.OfType<TypeASecondLevelObject>().Count(), 1);
                Assert.AreEqual(objects.OfType<TypeBSecondLevelObject>().Count(), 1);
                Assert.AreEqual(objects.OfType<TypeCSecondLevelObject>().Count(), 1);
            }
        }
Пример #2
0
        public static TopLevelObject GetEntityAsTopLevelObject(Guid uid)
        {
            TopLevelObject tlo = new TopLevelObject();

            var entity = EntityManager.GetEntity(uid, false);

            if (entity == null || entity.Id == 0)
            {
                return(null);
            }
            //
            if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL)
            {
                //actually should return some type info
                tlo = CredentialManager.GetBasic(entity.EntityBaseId);
                tlo.EntityTypeId = entity.EntityTypeId;
            }
            else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_ORGANIZATION)
            {
                tlo = OrganizationManager.GetBasics(entity.EntityUid);
                tlo.EntityTypeId = entity.EntityTypeId;
            }
            else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE)
            {
                tlo = AssessmentManager.GetBasic(entity.EntityBaseId);
                tlo.EntityTypeId = entity.EntityTypeId;
            }
            else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE)
            {
                tlo = LearningOpportunityManager.GetBasic(entity.EntityBaseId);
                tlo.EntityTypeId = entity.EntityTypeId;
            }
            else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_PATHWAY)
            {
                tlo = PathwayManager.GetBasic(entity.EntityBaseId);
                tlo.EntityTypeId = entity.EntityTypeId;
            }
            else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT)
            {
                tlo = PathwayComponentManager.Get(entity.EntityBaseId);
                tlo.EntityTypeId = entity.EntityTypeId;
            }
            else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_PATHWAY_SET)
            {
                tlo = PathwaySetManager.Get(entity.EntityBaseId);
                tlo.EntityTypeId = entity.EntityTypeId;
            }
            else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE)
            {
                tlo = TransferValueProfileManager.Get(entity.EntityBaseId);
                tlo.EntityTypeId = entity.EntityTypeId;
            }
            return(tlo);
        }