//------------------------------------------------------------------------------ // <auto-generated> // This code was generated from a template. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Runtime.Serialization; namespace VAL.Model { [DataContract()] public partial class Group : PocoEntityBase { #region Primitive Properties [EntityKey] [DataMember()] public virtual int Id { get; set; } [DataMember()] public virtual string Description { get; set; } [DataMember()] public virtual int GroupTypeID { get { return _groupTypeID; } set { if (_groupTypeID != value) { if (GroupType != null && GroupType.Id != value) { GroupType = null; } _groupTypeID = value; } } } private int _groupTypeID; [DataMember()] public virtual bool IsGroupActive { get; set; } #endregion #region Navigation Properties [IgnoreDataMember()] public virtual ICollection<GroupUser> GroupUsers { get { if (_groupUsers == null) { var newCollection = new FixupCollection<GroupUser>(); newCollection.CollectionChanged += FixupGroupUsers; _groupUsers = newCollection; } return _groupUsers; } set { if (!ReferenceEquals(_groupUsers, value)) { var previousValue = _groupUsers as FixupCollection<GroupUser>; if (previousValue != null) { previousValue.CollectionChanged -= FixupGroupUsers; } _groupUsers = value; var newValue = value as FixupCollection<GroupUser>; if (newValue != null) { newValue.CollectionChanged += FixupGroupUsers; } } } } private ICollection<GroupUser> _groupUsers; public virtual GroupType GroupType { get { return _groupType; } set { if (!ReferenceEquals(_groupType, value)) { var previousValue = _groupType; _groupType = value; FixupGroupType(previousValue); } } } private GroupType _groupType; [IgnoreDataMember()] public virtual ICollection<Permission> Permissions { get { if (_permissions == null) { var newCollection = new FixupCollection<Permission>(); newCollection.CollectionChanged += FixupPermissions; _permissions = newCollection; } return _permissions; } set { if (!ReferenceEquals(_permissions, value)) { var previousValue = _permissions as FixupCollection<Permission>; if (previousValue != null) { previousValue.CollectionChanged -= FixupPermissions; } _permissions = value; var newValue = value as FixupCollection<Permission>; if (newValue != null) { newValue.CollectionChanged += FixupPermissions; } } } } private ICollection<Permission> _permissions; #endregion #region Association Fixup private void FixupGroupType(GroupType previousValue) { if (previousValue != null && previousValue.Groups.Contains(this)) { previousValue.Groups.Remove(this); } if (GroupType != null) { if (!GroupType.Groups.Contains(this)) { GroupType.Groups.Add(this); } if (GroupTypeID != GroupType.Id) { GroupTypeID = GroupType.Id; } } } private void FixupGroupUsers(object sender, NotifyCollectionChangedEventArgs e) { if (e.NewItems != null) { foreach (GroupUser item in e.NewItems) { item.Group = this; } } if (e.OldItems != null) { foreach (GroupUser item in e.OldItems) { if (ReferenceEquals(item.Group, this)) { item.Group = null; } } } } private void FixupPermissions(object sender, NotifyCollectionChangedEventArgs e) { if (e.NewItems != null) { foreach (Permission item in e.NewItems) { item.Group = this; } } if (e.OldItems != null) { foreach (Permission item in e.OldItems) { if (ReferenceEquals(item.Group, this)) { item.Group = null; } } } } #endregion } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)