/DMS/Implementacion/PaucarpataSolution/PPR.Data/t_cap_clasifica.cs
http://ppp-eym.googlecode.com/ · C# · 238 lines · 208 code · 22 blank · 8 comment · 42 complexity · 8bb655c898a1b9dfcf306221a165b4e6 MD5 · raw file
- //------------------------------------------------------------------------------
- // <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.Generic;
- using System.Collections.ObjectModel;
- using System.Collections.Specialized;
- using System.ComponentModel;
- using System.Globalization;
- using System.Runtime.Serialization;
-
- namespace PPR.Data
- {
- [DataContract(IsReference = true)]
- [KnownType(typeof(t_cap_cargos))]
- public partial class t_cap_clasifica: IObjectWithChangeTracker, INotifyPropertyChanged
- {
- #region Primitive Properties
-
- [DataMember]
- public int id_clas
- {
- get { return _id_clas; }
- set
- {
- if (_id_clas != value)
- {
- if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
- {
- throw new InvalidOperationException("The property 'id_clas' is part of the object's key and cannot be changed. Changes to key properties can only be made when the object is not being tracked or is in the Added state.");
- }
- _id_clas = value;
- OnPropertyChanged("id_clas");
- }
- }
- }
- private int _id_clas;
-
- [DataMember]
- public string codigo
- {
- get { return _codigo; }
- set
- {
- if (_codigo != value)
- {
- _codigo = value;
- OnPropertyChanged("codigo");
- }
- }
- }
- private string _codigo;
-
- [DataMember]
- public string descripcion
- {
- get { return _descripcion; }
- set
- {
- if (_descripcion != value)
- {
- _descripcion = value;
- OnPropertyChanged("descripcion");
- }
- }
- }
- private string _descripcion;
-
- #endregion
- #region Navigation Properties
-
- [DataMember]
- public TrackableCollection<t_cap_cargos> t_cap_cargos
- {
- get
- {
- if (_t_cap_cargos == null)
- {
- _t_cap_cargos = new TrackableCollection<t_cap_cargos>();
- _t_cap_cargos.CollectionChanged += Fixupt_cap_cargos;
- }
- return _t_cap_cargos;
- }
- set
- {
- if (!ReferenceEquals(_t_cap_cargos, value))
- {
- if (ChangeTracker.ChangeTrackingEnabled)
- {
- throw new InvalidOperationException("Cannot set the FixupChangeTrackingCollection when ChangeTracking is enabled");
- }
- if (_t_cap_cargos != null)
- {
- _t_cap_cargos.CollectionChanged -= Fixupt_cap_cargos;
- }
- _t_cap_cargos = value;
- if (_t_cap_cargos != null)
- {
- _t_cap_cargos.CollectionChanged += Fixupt_cap_cargos;
- }
- OnNavigationPropertyChanged("t_cap_cargos");
- }
- }
- }
- private TrackableCollection<t_cap_cargos> _t_cap_cargos;
-
- #endregion
- #region ChangeTracking
-
- protected virtual void OnPropertyChanged(String propertyName)
- {
- if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
- {
- ChangeTracker.State = ObjectState.Modified;
- }
- if (_propertyChanged != null)
- {
- _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-
- protected virtual void OnNavigationPropertyChanged(String propertyName)
- {
- if (_propertyChanged != null)
- {
- _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-
- event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
- private event PropertyChangedEventHandler _propertyChanged;
- private ObjectChangeTracker _changeTracker;
-
- [DataMember]
- public ObjectChangeTracker ChangeTracker
- {
- get
- {
- if (_changeTracker == null)
- {
- _changeTracker = new ObjectChangeTracker();
- _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
- }
- return _changeTracker;
- }
- set
- {
- if(_changeTracker != null)
- {
- _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
- }
- _changeTracker = value;
- if(_changeTracker != null)
- {
- _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
- }
- }
- }
-
- private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
- {
- if (e.NewState == ObjectState.Deleted)
- {
- ClearNavigationProperties();
- }
- }
-
- protected bool IsDeserializing { get; private set; }
-
- [OnDeserializing]
- public void OnDeserializingMethod(StreamingContext context)
- {
- IsDeserializing = true;
- }
-
- [OnDeserialized]
- public void OnDeserializedMethod(StreamingContext context)
- {
- IsDeserializing = false;
- ChangeTracker.ChangeTrackingEnabled = true;
- }
-
- protected virtual void ClearNavigationProperties()
- {
- t_cap_cargos.Clear();
- }
-
- #endregion
- #region Association Fixup
-
- private void Fixupt_cap_cargos(object sender, NotifyCollectionChangedEventArgs e)
- {
- if (IsDeserializing)
- {
- return;
- }
-
- if (e.NewItems != null)
- {
- foreach (t_cap_cargos item in e.NewItems)
- {
- item.t_cap_clasifica = this;
- if (ChangeTracker.ChangeTrackingEnabled)
- {
- if (!item.ChangeTracker.ChangeTrackingEnabled)
- {
- item.StartTracking();
- }
- ChangeTracker.RecordAdditionToCollectionProperties("t_cap_cargos", item);
- }
- }
- }
-
- if (e.OldItems != null)
- {
- foreach (t_cap_cargos item in e.OldItems)
- {
- if (ReferenceEquals(item.t_cap_clasifica, this))
- {
- item.t_cap_clasifica = null;
- }
- if (ChangeTracker.ChangeTrackingEnabled)
- {
- ChangeTracker.RecordRemovalFromCollectionProperties("t_cap_cargos", item);
- }
- }
- }
- }
-
- #endregion
- }
- }