Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9225353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:33:20+00:00 2026-06-18T04:33:20+00:00

I want to retrieve each column name and data type then check if the

  • 0

I want to retrieve each column name and data type then check if the columns is foreign key then query they key table of that relation !!! could be done ?? I googled for 3 days I know that I have to use Mappping model OR Reflection or both ,,,, but i cant do it .

I will simplify what i need assuming :
TABLE1 hase foreign key( COL3) refer to the primary key (COL1) in TABLE0 :

  1. iterate TABLE1 Columns check EACH columns if it is a foreign key ( also get its data type)

  2. Get the relation to determine the associated table(TABLE0)

  3. retrieve the primary key tables (TABLE0)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:33:22+00:00Added an answer on June 18, 2026 at 4:33 am

    I got it
    I make a function that return the type of each foreign key and the related table class type

    Private Function GetForeignKeyTables(ByVal myTableType As Type) As List(Of myForeignKeys)
    
        Dim myDx = New Tester.DataClasses1DataContext
        Dim mymodel As New AttributeMappingSource
    
        Dim myAsociations = mymodel.GetModel(GetType(DataClasses1DataContext)).GetTable(myTableType).RowType.Associations
    
        Dim asc = From m In myAsociations Where m.IsForeignKey
                   Select New myForeignKeys With {.KeyDataType = m.ThisKey.First.DbType, .RelatedTableType = m.OtherType}
    
        Return asc.ToList
    
    End Function
    
    Private Class myForeignKeys
        Property KeyDataType As String
        Property RelatedTableType As MetaType
    
    End Class 
    

    But I still need to retrieve the data from those related table .

    I mean how to create an instance of the class from its MetaType variable?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to retrieve data from 2 columns of my database table and bind
I have a table with columns sales(int) , month(int) . I want to retrieve
My database structure contains columns: id, name, value, dealer . I want to retrieve
I want add the description of the table and description to each column in
I want to retrieve the CPU usage and memory usage of each process running
I have a HTML table as follows. I want retrieve row values from this
I want to retrieve/query images stored by joomla k2 component (under the Image Tab).
I want to retrieve the latitude and the longitude of a data which is
i have the following code. my problem is i want to retrieve each employee
I have two tables, keywords and data. Table keywords have 2 columns (id, keyword),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.