コード例 #1
0
        public static void UpdateConsultation(Consultation consultation)
        {
            SystemMedContainer context = new SystemMedContainer();

            context.Consultations.AddObject(consultation);
            context.ObjectStateManager.ChangeObjectState(consultation, EntityState.Modified);
            context.SaveChanges();

            //detaching the object - ablity to share between different contexts
            context.Detach(consultation);
        }
コード例 #2
0
        public static void DeleteConsultation(Consultation consultation)
        {
            SystemMedContainer context = new SystemMedContainer();

            if (consultation.EntityState == EntityState.Detached)
            {
                context.Consultations.Attach(consultation);
            }
            context.Consultations.DeleteObject(consultation);
            context.SaveChanges();
        }
コード例 #3
0
        public static void InsertConsultation(Consultation consultation)
        {
            SystemMedContainer context = new SystemMedContainer();

            if (consultation.EntityState != EntityState.Detached)
            {
                context.ObjectStateManager.ChangeObjectState(consultation, EntityState.Added);
            }
            else
            {
                context.Consultations.AddObject(consultation);
            }
            context.SaveChanges();
            //detaching the object - ablity to share between different contexts
            context.Detach(consultation);
        }