c# - Two different classes or one with unused properties -
i'm developing augmented reality windows phone 8.
this app have database, , i'm using linq-to-sql create it. table have app:
[table] public class arlocation : inotifypropertychanged, inotifypropertychanging { [column(dbtype = "int not null identity", isdbgenerated = true, isprimarykey = true)] public int arlocationid { get; private set; } private string name; private string description; private double latitude; private double longitude; [column] public string name { { return name; } set { if (name != value) { notifypropertychanging(); name = value; notifypropertychanged(); } } } [column] public string description { { return description; } set { if (name != value) { notifypropertychanging(); description = value; notifypropertychanged(); } } } [column] public double latitude { { return latitude; } set { if (latitude != value) { notifypropertychanging(); latitude = value; notifypropertychanged(); } } } [column] public double longitude { { return longitude; } set { if (longitude != value) { notifypropertychanging(); longitude = value; notifypropertychanged(); } } } public event propertychangingeventhandler propertychanging; public event propertychangedeventhandler propertychanged; private void notifypropertychanged([callermembername] string propertyname = "") { var propertychangedcopy = propertychanged; if (propertychangedcopy != null) { propertychangedcopy(this, new propertychangedeventargs(propertyname)); } } private void notifypropertychanging([callermembername] string propertyname = "") { var propertychangingcopy = propertychanging; if (propertychangingcopy != null) { propertychangingcopy(this, new propertychangingeventargs(propertyname)); } } }
but show data need column, called distance
.
this software design question:
do need 2 classes or maybe can add column arlocation class although don't use on database?
if need function or property calculates value safe add model class.
if need store extra, temporary value don't need save @ db may want use partial classes this. keep model clean , tidy.
Comments
Post a Comment