无法手动修改LINQ to sql产生的类!
下面是一个linq to sql产生的Person类
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行库版本:2.0.50727.1433
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace MemberDll.Person
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;
[System.Data.Linq.Mapping.DatabaseAttribute(Name="Member")]
public partial class PersonDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
#region Extensibility Method Definitions
partial void OnCreated();
partial void InsertPerson(Person instance);
partial void UpdatePerson(Person instance);
partial void DeletePerson(Person instance);
#endregion
public PersonDataContext() :
base("", mappingSource)
{
OnCreated();
}
public PersonDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public PersonDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public PersonDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public PersonDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public System.Data.Linq.Table<Person> Person
{
get
{
return this.GetTable<Person>();
}
}
}
[Table(Name="dbo.Person")]
public partial class Person : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
private string _PersonID;
private int _Category;
private string _PersonName;
private string _PassWord;
private System.DateTime _RegisterDate;
#region Extensibility Method Definitions
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
partial void OnCreated();
partial void OnPersonIDChanging(string value);
partial void OnPersonIDChanged();
partial void OnCategoryChanging(int value);
partial void OnCategoryChanged();
partial void OnPersonNameChanging(string value);
partial void OnPersonNameChanged();
partial void OnPassWordChanging(string value);
partial void OnPassWordChanged();
partial void OnRegisterDateChanging(System.DateTime value);
partial void OnRegisterDateChanged();
#endregion
public Person()
{
OnCreated();
}
[Column(Storage="_PersonID", DbType="NChar(10) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
public string PersonID
{
get
{
return this._PersonID;
}
set
{
if ((this._PersonID != value))
{
this.OnPersonIDChanging(value);
this.SendPropertyChanging();
this._PersonID = value;
this.SendPropertyChanged("PersonID");
this.OnPersonIDChanged();
}
}
}
[Column(Storage="_Category", DbType="Int NOT NULL")]
public int Category
{
get
{
return this._Category;
}
set
{
if ((this._Category != value))
{
this.OnCategoryChanging(value);
this.SendPropertyChanging();
this._Category = value;
this.SendPropertyChanged("Category");
this.OnCategoryChanged();
}
}
}
[Column(Storage="_PersonName", DbType="NVarChar(8) NOT NULL", CanBeNull=false)]
public string PersonName
{
get
{
return this._PersonName;
}
set
{
if ((this._PersonName != value))
{
this.OnPersonNameChanging(value);
this.SendPropertyChanging();
this._PersonName = value;
this.SendPropertyChanged("PersonName");
this.OnPersonNameChanged();
}
}
}
[Column(Storage="_PassWord", DbType="NChar(16)")]
public string PassWord
{
get
{
return this._PassWord;
}
set
{
if ((this._PassWord != value))
{
this.OnPassWordChanging(value);
this.SendPropertyChanging();
this._PassWord = value;
this.SendPropertyChanged("PassWord");
this.OnPassWordChanged();
}
}
}
[Column(Storage="_RegisterDate", DbType="DateTime NOT NULL")]
public System.DateTime RegisterDate
{
get
{
return this._RegisterDate;
}
set
{
if ((this._RegisterDate != value))
{
this.OnRegisterDateChanging(value);
this.SendPropertyChanging();
this._RegisterDate = value;
this.SendPropertyChanged("RegisterDate");
this.OnRegisterDateChanged();
}
}
}
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));
}
}
}
}
#pragma warning restore 1591
无法将该类继承别的类,就算你手动修改继承了。当你点到重建Person.DBML后所做的修改全部恢复了。也没有在将类中增加方法,属性。这样很大程度上限制了LINQ的灵活性。请问有什么办法可以解决?