Exemple #1
0
        private void Child_Update(Company company, Companies entityCompany)
        {
            using (var manager =
                       ObjectContextManager <RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
            {
                RolodexEF.Ranks newRank = GetRank(ReadProperty(RankIdProperty));
                RolodexEF.Ranks oldRank = GetRank(ReadProperty(InitialRankIdProperty));

                var newContact = new CompanyContacts();
                newContact.CompanyContactId = ReadProperty(CompanyContactIdProperty);
                newContact.EntityKey        = new System.Data.EntityKey("RolodexEntities.CompanyContacts", "CompanyContactId",
                                                                        ReadProperty(CompanyContactIdProperty));

                manager.ObjectContext.Attach(newContact);
                entityCompany.CompanyContacts.Attach(newContact);
                oldRank.CompanyContacts.Attach(newContact);
                newContact.Ranks = newRank;

                newContact.BaseSalary = ReadProperty(BaseSalaryProperty);
                var birthday = ReadProperty(BirthdayProperty);
                if (!birthday.IsEmpty)
                {
                    newContact.Birthday = birthday.Date;
                }
                else
                {
                    newContact.Birthday = null;
                }

                newContact.FirstName = ReadProperty(FirstNameProperty);
                newContact.LastName  = ReadProperty(LastNameProperty);

                DataPortal.UpdateChild(ReadProperty(ContactsPhonesProperty), this, newContact);
            }
        }
Exemple #2
0
        private void Child_Insert(Company company, Companies entityCompany)
        {
            using (var manager =
                       ObjectContextManager <RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
            {
                LoadProperty(CompanyIdProperty, company.CompanyId);
                RolodexEF.Ranks newRank = GetRank(ReadProperty(RankIdProperty));

                var newContact = new CompanyContacts();
                newContact.BaseSalary = ReadProperty(BaseSalaryProperty);
                var birthday = ReadProperty(BirthdayProperty);
                if (!birthday.IsEmpty)
                {
                    newContact.Birthday = birthday.Date;
                }
                newContact.Companies = entityCompany;
                newContact.FirstName = ReadProperty(FirstNameProperty);
                newContact.LastName  = ReadProperty(LastNameProperty);
                newContact.Ranks     = newRank;

                LoadProperty(InitialRankIdProperty, ReadProperty(RankIdProperty));
                if (ReadProperty(CompanyContactIdProperty) == 0)
                {
                    newContact.PropertyChanged += entityContact_PropertyChanged;
                }

                DataPortal.UpdateChild(ReadProperty(ContactsPhonesProperty), this, newContact);
            }
        }
Exemple #3
0
        private RolodexEF.Ranks GetRank(int rankID)
        {
            using (var manager =
                       ObjectContextManager <RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
            {
                RolodexEF.Ranks rank;

                System.Data.EntityKey rankKey = new System.Data.EntityKey("RolodexEntities.Ranks", "RankId", rankID);

                System.Data.Objects.ObjectStateEntry entry;
                if (!manager.ObjectContext.ObjectStateManager.TryGetObjectStateEntry(rankKey, out entry))
                {
                    rank           = new RolodexEF.Ranks();
                    rank.RankId    = rankID;
                    rank.EntityKey = rankKey;
                    manager.ObjectContext.Attach(rank);
                }
                else
                {
                    rank = entry.Entity as RolodexEF.Ranks;
                }

                return(rank);
            }
        }
        /// <summary>
        /// Create a new Ranks object.
        /// </summary>
        /// <param name="rankId">Initial value of the RankId property.</param>
        /// <param name="rank">Initial value of the Rank property.</param>
        public static Ranks CreateRanks(global::System.Int32 rankId, global::System.String rank)
        {
            Ranks ranks = new Ranks();

            ranks.RankId = rankId;
            ranks.Rank   = rank;
            return(ranks);
        }
Exemple #5
0
        internal static Rank GetRank(RolodexEF.Ranks rank)
        {
            Rank fetchedRank = new Rank();

            fetchedRank.LoadProperty <int>(RankIdProperty, rank.RankId);
            fetchedRank.LoadProperty <string>(RankNameProperty, rank.Rank);
            fetchedRank.MarkOld();
            return(fetchedRank);
        }
Exemple #6
0
 protected override void DataPortal_Insert()
 {
     using (ObjectContextManager <RolodexEntities> manager = ObjectContextManager <RolodexEF.RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
     {
         RolodexEF.Ranks newRank = new RolodexEF.Ranks();
         newRank.Rank = ReadProperty(RankNameProperty);
         manager.ObjectContext.AddToRanks(newRank);
         manager.ObjectContext.SaveChanges();
         LoadProperty(RankIdProperty, newRank.RankId);
     }
 }
Exemple #7
0
        protected override void DataPortal_Update()
        {
            using (ObjectContextManager <RolodexEntities> manager = ObjectContextManager <RolodexEF.RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
            {
                RolodexEF.Ranks newRank = new RolodexEF.Ranks();
                newRank.RankId    = ReadProperty(RankIdProperty);
                newRank.EntityKey = new System.Data.EntityKey("RolodexEntities.Ranks", "RankId", newRank.RankId);
                manager.ObjectContext.Attach(newRank);

                newRank.Rank = ReadProperty(RankNameProperty);
                manager.ObjectContext.SaveChanges();
            }
        }
Exemple #8
0
 protected override void DataPortal_DeleteSelf()
 {
     if (!this.IsNew)
     {
         using (ObjectContextManager <RolodexEntities> manager = ObjectContextManager <RolodexEF.RolodexEntities> .GetManager(DataConnection.EFConnectionName, true))
         {
             RolodexEF.Ranks deleted = new RolodexEF.Ranks();
             deleted.RankId    = ReadProperty(RankIdProperty);
             deleted.EntityKey = new System.Data.EntityKey("RolodexEntities.Ranks", "RankId", deleted.RankId);
             manager.ObjectContext.Attach(deleted);
             manager.ObjectContext.DeleteObject(deleted);
             manager.ObjectContext.SaveChanges();
         }
     }
 }
Exemple #9
0
 /// <summary>
 /// Create a new Ranks object.
 /// </summary>
 /// <param name="rankId">Initial value of the RankId property.</param>
 /// <param name="rank">Initial value of the Rank property.</param>
 public static Ranks CreateRanks(global::System.Int32 rankId, global::System.String rank)
 {
     Ranks ranks = new Ranks();
     ranks.RankId = rankId;
     ranks.Rank = rank;
     return ranks;
 }
Exemple #10
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Ranks EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRanks(Ranks ranks)
 {
     base.AddObject("Ranks", ranks);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Ranks EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRanks(Ranks ranks)
 {
     base.AddObject("Ranks", ranks);
 }