This question is locked. New answers and comments are not allowed.
Hi
I have an existing project that I am trying to convert to a database (SQLite). I'm struggling conceptually on how I would approach a particular configuration I have currently.
When I read the data from the current source (serial data) I perform a conversion on some elements based on the configuration of the app. In this instance I'm reading speed as meters/sec and do a conversion in the class. This is the code I have currently:
public float telSpeed
{
//value in m/s
get { return telspeed; }
set
{
if (telspeed == value)
return;
telSpeedAdjusted = value;
SetProperty(ref telspeed, value);
}
}
public float telSpeedAdjusted
{
get { return telspeedadjusted; }
set
{
if (telspeedadjusted == value)
return;
switch (SPEED_DISPLAY)
{
case eSpeedDisplay.Speed_MPH:
value = (float)(Math.Round(value * 2.24, 0)); //convert to MPH
break;
case eSpeedDisplay.Speed_KPH:
value = (float)(Math.Round(value * 3.6, 0)); //convert to KPH
break;
case eSpeedDisplay.Speed_MPS:
//don't convert from m/s this is what the data is in
break;
default:
break;
}
SetProperty(ref telspeedadjusted, value);
}
}
In my WPF I bind to the telSpeedAdjusted property. If I convert this class over to a SQLite DB and get autogenerated properties, how can I perform the same conversion?
I appreciate it could be done as a valueconverter, but I don't really want to do this. There are other properties that are referenced in the WPF multiple times and it does impact performance. I'm not that experienced with C# and even less with database design and am really struggling conceptually to figure a way around this.
Can anyone assist a flailing noob?
I have an existing project that I am trying to convert to a database (SQLite). I'm struggling conceptually on how I would approach a particular configuration I have currently.
When I read the data from the current source (serial data) I perform a conversion on some elements based on the configuration of the app. In this instance I'm reading speed as meters/sec and do a conversion in the class. This is the code I have currently:
public float telSpeed
{
//value in m/s
get { return telspeed; }
set
{
if (telspeed == value)
return;
telSpeedAdjusted = value;
SetProperty(ref telspeed, value);
}
}
public float telSpeedAdjusted
{
get { return telspeedadjusted; }
set
{
if (telspeedadjusted == value)
return;
switch (SPEED_DISPLAY)
{
case eSpeedDisplay.Speed_MPH:
value = (float)(Math.Round(value * 2.24, 0)); //convert to MPH
break;
case eSpeedDisplay.Speed_KPH:
value = (float)(Math.Round(value * 3.6, 0)); //convert to KPH
break;
case eSpeedDisplay.Speed_MPS:
//don't convert from m/s this is what the data is in
break;
default:
break;
}
SetProperty(ref telspeedadjusted, value);
}
}
In my WPF I bind to the telSpeedAdjusted property. If I convert this class over to a SQLite DB and get autogenerated properties, how can I perform the same conversion?
I appreciate it could be done as a valueconverter, but I don't really want to do this. There are other properties that are referenced in the WPF multiple times and it does impact performance. I'm not that experienced with C# and even less with database design and am really struggling conceptually to figure a way around this.
Can anyone assist a flailing noob?