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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:49:15+00:00 2026-05-23T12:49:15+00:00

I have to update an existing site that’s based on DDS on top of

  • 0

I have to update an existing site that’s based on DDS on top of the Entity Framework, and it uses three different database models from three different databases. And what it needs is a simple addition to the ListDetails page: an export to XML button…
Adding the button is easy. Creating the XML isn’t difficult either. The challenge is getting the proper table to export, walk through all records and fields and generate the XML based on any of the 100+ tables in the system!
So, my button calls an export (ashx) handler which generates the XML based on the table who’se name it receives through it’s parameters. The code I have is something like this:

        Content_CobaEntities Coba = new Content_CobaEntities();
        MetadataWorkspace metadataWorkspace = Coba.MetadataWorkspace;
        EntityContainer container = metadataWorkspace.GetItems<EntityContainer>(DataSpace.CSpace).First();
        string namespaceName = metadataWorkspace.GetItems<EntityType>(DataSpace.CSpace).First().NamespaceName;
        EntitySetBase entitySetBase = container.BaseEntitySets.FirstOrDefault(set => set.ElementType.Name == Entity);

Unfortunately, this only works with a single context and I happen to have three. (But this one is the main context.) (Besides, a second parameter could be used to determine the proper context.) And although it allows me to determine the entity type that’s needed, it still won’t provide me access to it’s records and fields.

So, how to I get the data for this entity? (Filters aren’t important; the export will return all data.)

And no, no EF4. No .NET 4. This is an older VS2008 project and cannot be modified to much, nor can it be upgraded…


Basically, the querystring contains two parameters: ContextID and QueryID. The ContextID tells me which context to use and since I only have three different contexts, a simple switch-command solves this for me.
But one of the contexts contains 60+ queries, each of them related to a single database table. The Dynamic Data Site provides me with options to add, edit and delete records from this table but it needs to be exported in a format dictated by my custom code. But with 60 tables, it’s too much to write a switch statement for each and every query so I need something more generic.

  • 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-05-23T12:49:16+00:00Added an answer on May 23, 2026 at 12:49 pm

    As it turns out, I made things more complex than needed… I start with the parameters:

            string Entity = context.Request.QueryString.Get("Entity");
            string ContextID = context.Request.QueryString.Get("Context");
    

    Then I need to determine the right context to use, which is easy:

            ObjectContext Context;
            if (ContextID.Contains("Content_LogEntities")) { Context = new Content_LogEntities(); }
            else if (ContextID.Contains("Content_CobusEntities")) { Context = new Content_CobusEntities(); }
            else { Context = new Content_CobaEntities(); };
    

    Next I need to get the proper data in the requested table. Also easy:

            ObjectQuery Tabel = Context.CreateQuery<EntityObject>(string.Format("[{0}]", Entity));
    

    Don’t know why I was trying to make that part more complex than needed.

    What’s left is walking through all fields, but I have a reflection work-around:

            foreach (var rec in Tabel)
            {
                foreach (PropertyInfo Prop in rec.GetType().GetProperties())
                {
                    // Blah
                }
            }
    

    The Blah-part checks the Prop.Name To see if it’s an entity key, entity state, child collection or reference or if it’s just a data-field. This allows me to generate a practical XML output.

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

Sidebar

Related Questions

I am using ColdFusion 9.0.1. I have a new web site that uses Bikes.cfm
I have made a site that is based off of a MasterPage and after
We have a very large existing site that we're going to do a completely
I have been following the answer of this question: How to update existing object
I have update panel that content check box, textbox, 3 DropDownList with CascadingDropDown extender.
I use oracle 10. I have update statement like that : update table1 t1
I have to update different server data which takes huge time. I have to
I have an UPDATE statement that's intended to update a status field for a
I have an update program that is completely independent of my main application. I
While working on an existing Drupal site I've noticed a strange glitch that causes

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.