This is a migrated thread and some comments may be shown as answers.

Mapping Existing Code Functionality to a Database Approach

2 Answers 36 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mike
Top achievements
Rank 1
Mike asked on 03 May 2014, 03:15 AM
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?

2 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 05 May 2014, 03:00 PM
Hi Mike,

I would use the Telerik Data Access fluent mapping approach as described here. You can either reuse your existing classes and just add the mapping or you define a new set of classes with a copy ctor.


Regards,
Jan Blessenohl
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Mike
Top achievements
Rank 1
answered on 07 May 2014, 08:42 PM
Thanks, I'll have a dig into the Fluent stuff over the weekend...
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Mike
Top achievements
Rank 1
Share this question
or