Я создал этот класс с помощью SQLMetal.exe.Это очень привязка во время выполнения, но если я использую этот класс во время разработки, все мои привязки при проектировании смешиваются.
Я использую инфраструктуру MVVM-Light и создаю приложение для WP7.
Если я извлекаю интерфейс для этого класса и создаю простое POCO, которое реализует этот интерфейс, и я использую мое простое poco в своем источнике данных времени разработки, все привязки оживают.
Вот класс, который был сгенерирован SQLMetal.exe.
[Table(Name="InspectionGroup")]
public partial class InspectionGroup : INotifyPropertyChanging, INotifyPropertyChanged, IInspectionGroup
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private int _InspectionGroupId;
private string _GroupName;
private System.DateTime _DateCreated;
private EntitySet<InspectionHeader> _InspectionHeaders;
private EntitySet<InspectionPoint> _InspectionPoints;
#region Extensibility Method Definitions
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnInspectionGroupIdChanging(int value);
partial void OnInspectionGroupIdChanged();
partial void OnGroupNameChanging(string value);
partial void OnGroupNameChanged();
partial void OnDateCreatedChanging(System.DateTime value);
partial void OnDateCreatedChanged();
#endregion
public InspectionGroup()
{
this._InspectionHeaders = new EntitySet<InspectionHeader>(new Action<InspectionHeader>(this.attach_InspectionHeaders), new Action<InspectionHeader>(this.detach_InspectionHeaders));
this._InspectionPoints = new EntitySet<InspectionPoint>(new Action<InspectionPoint>(this.attach_InspectionPoints), new Action<InspectionPoint>(this.detach_InspectionPoints));
OnCreated();
}
[Column(Storage = "_InspectionGroupId", AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
public int InspectionGroupId
{
get
{
return this._InspectionGroupId;
}
set
{
if ((this._InspectionGroupId != value))
{
this.OnInspectionGroupIdChanging(value);
this.SendPropertyChanging();
this._InspectionGroupId = value;
this.SendPropertyChanged("InspectionGroupId");
this.OnInspectionGroupIdChanged();
}
}
}
[Column(Storage = "_GroupName", DbType = "NVarChar(100) NOT NULL", CanBeNull = false)]
public string GroupName
{
get
{
return this._GroupName;
}
set
{
if ((this._GroupName != value))
{
this.OnGroupNameChanging(value);
this.SendPropertyChanging();
this._GroupName = value;
this.SendPropertyChanged("GroupName");
this.OnGroupNameChanged();
}
}
}
[Column(Storage = "_DateCreated", DbType = "DateTime NOT NULL")]
public System.DateTime DateCreated
{
get
{
return this._DateCreated;
}
set
{
if ((this._DateCreated != value))
{
this.OnDateCreatedChanging(value);
this.SendPropertyChanging();
this._DateCreated = value;
this.SendPropertyChanged("DateCreated");
this.OnDateCreatedChanged();
}
}
}
[Association(Name = "FK_InspectionHeader_InspectionGroup", Storage = "_InspectionHeaders", ThisKey = "InspectionGroupId", OtherKey = "InspectionGroupId", DeleteRule = "CASCADE")]
public EntitySet<InspectionHeader> InspectionHeaders
{
get
{
return this._InspectionHeaders;
}
set
{
this._InspectionHeaders.Assign(value);
}
}
[Association(Name = "FK_InspectionPoint_InspectionGroup", Storage = "_InspectionPoints", ThisKey = "InspectionGroupId", OtherKey = "InspectionGroupId", DeleteRule = "CASCADE")]
public EntitySet<InspectionPoint> InspectionPoints
{
get
{
return this._InspectionPoints;
}
set
{
this._InspectionPoints.Assign(value);
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
if ((this.PropertyChanging != null))
{
this.PropertyChanging(this, emptyChangingEventArgs);
}
}
protected virtual void SendPropertyChanged(String propertyName)
{
if ((this.PropertyChanged != null))
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private void attach_InspectionHeaders(InspectionHeader entity)
{
this.SendPropertyChanging();
entity.InspectionGroup = this;
}
private void detach_InspectionHeaders(InspectionHeader entity)
{
this.SendPropertyChanging();
entity.InspectionGroup = null;
}
private void attach_InspectionPoints(InspectionPoint entity)
{
this.SendPropertyChanging();
entity.InspectionGroup = this;
}
private void detach_InspectionPoints(InspectionPoint entity)
{
this.SendPropertyChanging();
entity.InspectionGroup = null;
}
}