I\'m working with a third-party database in which all text values are stored as char(n). Some of these text values are primary keys, whereas others are just nor
Use properties with backing fields instead of automatic properties on your entities.
Add the "Trim()" in the property setter, like so:
protected string _name;
public String Name
{
get { return this._name; }
set { this._name = (value == null ? value : value.Trim()); }
}
I wrote my own POCO generator that just does this automatically, but if you don't have an option like that, ReSharper can add backing fields to automatic properties in like two keystrokes. Just do it for strings, and you can do a global (at the file scope) find/replace for " = value;" with "= value.Trim();".