none
Linq reflection for parent table

    Dotaz

  • Hello,

    I need to process general query of Linq.
    I am able to process simple table - get both types of columns and their values:

    dim query = from x in myData.table
    
    dim dr = query(0)
    
    For each prop in dr.GetType.GetProperties
      dim PN = prop.Name
      dim PFN = prop.FullName
      ...
    next

    I have problem with related tables:

    dim query = from x in myData.table select x, x.parentTable.firstName, x.ParentTable.lastName
    
    dim dr = query(0)
    
    For each prop in dr.GetType.GetProperties
      dim PN = prop.Name
      dim PFN = prop.FullName
      ...
      
      if PFN.StartsWith("myAppName") then
        For each prop1 in prop.GetType.GetProperties
          dim PN1 = prop1.Name
          dim PFN1 = prop1.FullName
          ...
        Next
      else
        ...
      end if
    next

    The problem is in inner loop, where I cannot access right object.

    Thanks a lot for your help.

    Miroslav

    16. dubna 2016 10:19

Odpovědi

  • Hello,

    finally I solved the problem myself:

    dim query = from x in myData.table select x, x.parentTable.firstName, x.ParentTable.lastName
    
    dim dr = query(0)
    
    For each prop in dr.GetType.GetProperties
      dim PN = prop.Name
      dim PFN = prop.FullName
      ...
      
      if PFN.StartsWith("myAppName") then
        For each prop1 in prop.PropertyType.GetProperties
          dim PN1 = prop1.Name
          dim PFN1 = prop1.FullName
          ...
        Next
      else
        ...
      end if
    next
    Mirek


    18. dubna 2016 13:41