//------------------------------------------------------------------------------
//
// This code was generated from a template.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
namespace WNS.Entities
{
public partial class Organization
{
#region Primitive Properties
public virtual int Id
{
get;
set;
}
public virtual string Name
{
get;
set;
}
#endregion
#region Navigation Properties
public virtual ICollection Devision
{
get
{
if (_devision == null)
{
var newCollection = new FixupCollection();
newCollection.CollectionChanged += FixupDevision;
_devision = newCollection;
}
return _devision;
}
set
{
if (!ReferenceEquals(_devision, value))
{
var previousValue = _devision as FixupCollection;
if (previousValue != null)
{
previousValue.CollectionChanged -= FixupDevision;
}
_devision = value;
var newValue = value as FixupCollection;
if (newValue != null)
{
newValue.CollectionChanged += FixupDevision;
}
}
}
}
private ICollection _devision;
public virtual ICollection Contact
{
get
{
if (_contact == null)
{
var newCollection = new FixupCollection();
newCollection.CollectionChanged += FixupContact;
_contact = newCollection;
}
return _contact;
}
set
{
if (!ReferenceEquals(_contact, value))
{
var previousValue = _contact as FixupCollection;
if (previousValue != null)
{
previousValue.CollectionChanged -= FixupContact;
}
_contact = value;
var newValue = value as FixupCollection;
if (newValue != null)
{
newValue.CollectionChanged += FixupContact;
}
}
}
}
private ICollection _contact;
public virtual ICollection ContactInformation
{
get
{
if (_contactInformation == null)
{
var newCollection = new FixupCollection();
newCollection.CollectionChanged += FixupContactInformation;
_contactInformation = newCollection;
}
return _contactInformation;
}
set
{
if (!ReferenceEquals(_contactInformation, value))
{
var previousValue = _contactInformation as FixupCollection;
if (previousValue != null)
{
previousValue.CollectionChanged -= FixupContactInformation;
}
_contactInformation = value;
var newValue = value as FixupCollection;
if (newValue != null)
{
newValue.CollectionChanged += FixupContactInformation;
}
}
}
}
private ICollection _contactInformation;
public virtual WebMapService WebMapService
{
get { return _webMapService; }
set
{
if (!ReferenceEquals(_webMapService, value))
{
var previousValue = _webMapService;
_webMapService = value;
FixupWebMapService(previousValue);
}
}
}
private WebMapService _webMapService;
#endregion
#region Association Fixup
private void FixupWebMapService(WebMapService previousValue)
{
if (previousValue != null && ReferenceEquals(previousValue.Organization, this))
{
previousValue.Organization = null;
}
if (WebMapService != null)
{
WebMapService.Organization = this;
}
}
private void FixupDevision(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (Devision item in e.NewItems)
{
item.Organization = this;
}
}
if (e.OldItems != null)
{
foreach (Devision item in e.OldItems)
{
if (ReferenceEquals(item.Organization, this))
{
item.Organization = null;
}
}
}
}
private void FixupContact(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (Contact item in e.NewItems)
{
item.Organization = this;
}
}
if (e.OldItems != null)
{
foreach (Contact item in e.OldItems)
{
if (ReferenceEquals(item.Organization, this))
{
item.Organization = null;
}
}
}
}
private void FixupContactInformation(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.NewItems != null)
{
foreach (ContactInformation item in e.NewItems)
{
item.Organization = this;
}
}
if (e.OldItems != null)
{
foreach (ContactInformation item in e.OldItems)
{
if (ReferenceEquals(item.Organization, this))
{
item.Organization = null;
}
}
}
}
#endregion
}
}