I'm trying to get a series of record values from 21 consecutive fields named DP1 to DP21. I can write a query for each of the 21 values, but I'd prefer to get the values in a loop or dictionary etc.
    'this works, but requires 21 separate queries
    Dim QRY = (From mc In DATA.MONTE_CARLOs
                       Where mc.BOOK_COMP = "BOOK" And mc.GREEK = "SPOT"
                       Select mc.DP1).Distinct()
'I would prefer to dynamically get the values in a loop/dictionary etc
For x = 1 To 21
            Dim RCD = "mc.DP" & CStr(x)
            Dim QRY = (From mc In DATA.MONTE_CARLOs
                       Where mc.BOOK_COMP = "BOOK" And mc.GREEK = "SPOT"
                       Select RCD).Distinct()       'compile error on RCD
            'manipulate QRY and loop to get the next column value
        Next
I've read about reflection and Dynamic Linq, which should I use or is there a simple solution?
 
Aucun commentaire:
Enregistrer un commentaire