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 8947293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:43:21+00:00 2026-06-15T12:43:21+00:00

I have 3 entities: 1. A database 2. Table which database has a collection

  • 0

I have 3 entities:
1. A database
2. Table which database has a collection of
3. Column which tables have a collection of

While lazy loading enabled = false

How do I return a json string containing each database, with an array of respective tables, each table with an array of respective columns?

UPDATE:

I have have been able to return the following Json script, at the cost of disabling instances on certain classes:

enter image description here

This is the return I am looking for. However, I had to line-out column’s relationship to table, and table’s to database in respective classes and I did not want to do that.

I did first try the [ScriptIgnore] annotation over the foreign classes but that did not work

  • 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-15T12:43:22+00:00Added an answer on June 15, 2026 at 12:43 pm

    With clarification that these are custom-created objects, I believe you are looking to use reflection. Specifically the PropertyInfo class which is returned from calling Object.GetType() will give you what you want. If you have an object graph of database objects with table child objects and column grandchild objects, you should iterate through the graph, calling GetType() on each to acquire information about the names and types if needed.

    Reflection is not fast and performant, but it should get what you need.

    If the objects you are referencing are from a database technology:

    Look at Context.MetaDataWorkspace. Specifically look at .GetItems(). Here is a good example/demo showing you how to do it. Look at the ‘EntityTypes’ and ‘EntityTypes and Properties’ sections.

    Excerpted code:

    var query = from meta in context.MetadataWorkspace.GetItems(DataSpace.CSpace)
            where meta.BuiltInTypeKind == BuiltInTypeKind.EntityType
            select (meta as EntityType).Name;
    

    This will get you the list of tables and columns. You will not be able to get the list of databases on a given SQL server from an Entity context that is aware of only the items added to it and you do not add databases to a context.

    I also just noticed you requested that you be able to return it in JSON; with the result set above, you should be able to loop through and either build the JSON by hand or construct an object that is serializable as JSON.

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

Sidebar

Related Questions

I have a table Donations which has a CampaignID column that relates to the
I have two database tables: 'MyTable' which has a standard auto-incrementing primary key integer
Currently I have a database with the following relationships: One Client has multiple Entities
I have a Silverlight 4 app which pulls entities down from a database using
I have a schema which has 6 different types of entities, but they all
I have one application which uses NHibernate to save entities to a database, and
I have an existing application that has the following entities in the database Customer
I have two classes that represent two different database entities. Their relationship is 1:m
I have the following scenario: Entities are loaded from the database. One of them
Consider the following scenario We have a simple database that involves two entities: user

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.