Exemple #1
0
 public virtual void StartTracking()
 {
     if (ChangeTracker.ChangeTrackingEnabled)
     {
         return;
     }
     ChangeTracker.ChangeTrackingEnabled = true;
     if (NewsCategory != null)
     {
         NewsCategory.StartTracking();
     }
 }
Exemple #2
0
        private void FixupNewsCategory(NewsCategory previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.News.Contains(this))
            {
                previousValue.News.Remove(this);
            }

            if (NewsCategory != null)
            {
                if (!NewsCategory.News.Contains(this))
                {
                    NewsCategory.News.Add(this);
                }

                CategoryPk = NewsCategory.CategoryPk;
            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("NewsCategory") &&
                    (ChangeTracker.OriginalValues["NewsCategory"] == NewsCategory))
                {
                    ChangeTracker.OriginalValues.Remove("NewsCategory");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("NewsCategory", previousValue);
                }
                if (NewsCategory != null && !NewsCategory.ChangeTracker.ChangeTrackingEnabled)
                {
                    NewsCategory.StartTracking();
                }
            }
        }
Exemple #3
0
        public virtual object Clone(Dictionary <object, object> clonedObjects, bool includePrimaryKey)
        {
            NewsCategory cloned = new NewsCategory();

            clonedObjects.Add(this, cloned);
            if (includePrimaryKey)
            {
                cloned._categoryPk = this._categoryPk;
            }
            cloned._categoryTitle              = this._categoryTitle;
            cloned._audit_CreatorUserName      = this._audit_CreatorUserName;
            cloned._audit_CreateDate           = this._audit_CreateDate;
            cloned._audit_CreatorIP            = this._audit_CreatorIP;
            cloned._audit_LastModifyDate       = this._audit_LastModifyDate;
            cloned._audit_LastModifierUserName = this._audit_LastModifierUserName;
            cloned._audit_LastModifierIP       = this._audit_LastModifierIP;
            cloned._isListable = this._isListable;
            cloned._code       = this._code;

            if (News != null)
            {
                cloned.News = new TrackableCollection <News>();
                foreach (News item in News)
                {
                    if (!clonedObjects.ContainsKey(item))
                    {
                        cloned.News.Add((News)item.Clone(clonedObjects, includePrimaryKey));
                    }
                    else
                    {
                        cloned.News.Add((News)clonedObjects[item]);
                    }
                }
            }


            return(cloned);
        }
Exemple #4
0
        public virtual bool Equals(object other, List <object> checked_objects)
        {
            if (checked_objects.Contains(this))
            {
                return(true);
            }

            checked_objects.Add(this);

            NewsCategory casted_other = other as NewsCategory;

            if (casted_other == null)
            {
                checked_objects.Remove(this);
                return(false);
            }

            if (!Typing.IsEquals(this.CategoryPk, casted_other.CategoryPk))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.CategoryTitle, casted_other.CategoryTitle))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorUserName, casted_other.Audit_CreatorUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreateDate, casted_other.Audit_CreateDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_CreatorIP, casted_other.Audit_CreatorIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifyDate, casted_other.Audit_LastModifyDate))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierUserName, casted_other.Audit_LastModifierUserName))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Audit_LastModifierIP, casted_other.Audit_LastModifierIP))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.IsListable, casted_other.IsListable))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (!Typing.IsEquals(this.Code, casted_other.Code))
            {
                checked_objects.Remove(this);
                return(false);
            }
            if (this.News.Count != casted_other.News.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }
            List <int> News_compared = new List <int>(this.News.Count);

            for (int i = 0; i < this.News.Count; ++i)
            {
                if (this.News[i] != null)
                {
                    bool found = false;
                    for (int j = 0; j < this.News.Count; ++j)
                    {
                        if (News_compared.Contains(j))
                        {
                            continue;
                        }
                        if (this.News[i].Equals(casted_other.News[j], checked_objects))
                        {
                            News_compared.Add(j);
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        checked_objects.Remove(this);
                        return(false);
                    }
                }
                else
                {
                    for (int j = 0; j < this.News.Count; ++j)
                    {
                        if (News_compared.Contains(j))
                        {
                            continue;
                        }
                        if (casted_other.News[j] == null)
                        {
                            News_compared.Add(j);
                            break;
                        }
                    }
                }
            }

            if (News_compared.Distinct().Count() != this.News.Count)
            {
                checked_objects.Remove(this);
                return(false);
            }

            checked_objects.Remove(this);

            return(true);
        }