Override linq attribute c #

[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Gender", DbType="Int NOT NULL", UpdateCheck=UpdateCheck.Never)]
public int Gender
{
    get
    {
        return this._Gender;
    }
    set
    {
        if ((this._Gender != value))
        {
            this.OnGenderChanging(value);
            this.SendPropertyChanging();
            this._Gender = value;
            this.SendPropertyChanged("Gender");
            this.OnGenderChanged();
        }
    }
}

      

there is an attribute for update check

which i have set in never

. But when i made a small change in dbml i have to set this property of that field again. How can I override this attribute permanently in a partial class?

Update: As an example, I can change the dbml connection string like this, once for all:

partial class DataBaseDataContext : System.Data.Linq.DataContext
{
    public DataBaseDataContext() :
        base(ConfigurationManager.ConnectionStrings["MyConnection"].ToString())
    {
        OnCreated();
    }
}

      

+3


source to share


2 answers


I found this solution which does the same / similar to what you are asking for. You should probably take a look at this. The code uses reflection to find the correct column and makes the necessary changes. You will need to tweak it according to your scenario and see if you are happy with how it works.



+1


source


Open the dbml file in a designer and set the Update Check

property to the desired value. Do not modify the generated files directly, they will be overwritten.



enter image description here

+1


source







All Articles