c# - Custom Properties in Linq Generated Tables -


it makes more sense use integer in database, want pretend it's been string (and not string corresponding int) because it's simpler.

the reason behind user-facing view encrypted version of string, never want see int unless working directly database (the int identity column).

so, have linq mapping want replace. basically, wish replace (which in designer)

[global::system.data.linq.mapping.columnattribute] //... public int tid {         {         return this._tid;     }     set     {         if ((this._tid != value))         {             this.ontidchanging(value);             this.sendpropertychanging();             this._tid = value;             this.sendpropertychanged("tid");             this.ontidchanged();         }     } } 

with this

[global::system.data.linq.mapping.columnattribute] //... public string tid {         {         return convert.tostring(this._tid + 5);     }     set     {         if ((this._tid - 5 != int32.parse(value)))         {             this.ontidchanging(value);             this.sendpropertychanging();             this._tid = int32.parse(value) - 5;             this.sendpropertychanged("tid");             this.ontidchanged();         }     } } 

this allow me to, example, use asp:querystringparameter in whereparameters of linqdatasource instead of remapping query string in code-behind.

instead of remapping try extending linq class , adding new property class

public string tidstring { { return (this.tid + 5).tostring(); } set     {        int val = 0;        if (int.tryparse(value, out val)            this.tid = val - 5;        else            throw new exception("invalid tid value")     }  } 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -