Data conversion best implementation. RRS feed

  • Question

  • Hello,

    In my database, i store music key chords as Integers, when i display them on the GridView,
    i convert them in a more convenient format (example : key chord "Bminor" is stored as "17" in my database)

    At what time and how shall i convert the values ?

    I thought about creating a DataView of my data, update this view and present it on the UI.

    Do you know what is the best thing to do ?

    Thanks a lot,

    Thursday, June 12, 2008 2:35 PM

All replies

  • I think that you could convert it in UI layer. Sice you could display "17" as "Bminor" or "B#" (am I right? my music is pooor...) or "7#" (at least I'm sure that B is 7 ^_^) or something else, and the UI decide what to display for "17". I think if you could store the mapping relationship in UI layer, it is good. That is to say, it is converted just before the chords are displayed.

    Monday, June 16, 2008 11:10 AM
  • Hi,


    Yes B is number 7 but only for the C scale


    I started out to do like you said but I found it somewhat rigid,

    Actually i am thinking about using IValueConverter because i'm doing a WPF app.


    Well I don't really know yet, i let some time pass and i'll take a decision,


    Do you know any good links on the internet about this domain ?


    Thank you !




    Monday, June 16, 2008 9:01 PM
  • Actually I don't think you need to use IValueConverter.


    public string ConvertChords(int chord)

    if(chord == 0)

    return "C";

    else if(chord == 1)

    return "D";

    else if(chord == 2)

    return "E";

    else if ....... //something like this




    It's great to have things well done but it's important to have things done, huh?

    Tuesday, June 17, 2008 5:52 AM

    I'm considering it because it is worth for me, if the IValueConverter converts only the DataView itself, not the data directly.


    Any clues are welcome, we are discussing this in



    Thank you,

    Tuesday, June 17, 2008 5:15 PM