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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:15:48+00:00 2026-05-21T14:15:48+00:00

I want to expose the contents of a SQL database as an OData feed

  • 0

I want to expose the contents of a SQL database as an OData feed using WCF Data Service.

Everything works well as long as the SQL database schema is unchanged. Once a database table is added or altered the Entity model is out of date. Recompiling the data service is not an option as the schema can change several times a day.

I am defining a table data service:

public class TablesDataService
{
    private static List<Table> _tables;

    static TablesDataService()
    {
        _tables = new List<Table>();
        // query the database and add a table entity model for each table
    }

    public IQueryable<Table> Tables
    {
        get { return _tables.AsQueryable<Table>(); }
    }
}

which uses the following POCO to represent an individual table:

[DataServiceKey("Name")]
public class Table
{
    public Table(string name)
    {
        Name = name;
    }

    public string Name { get; private set; }
}

The WCF Data Service uses for following class in WcfDataService.svc:

public class WcfDataService : DataService<TablesDataService>
{
    public static void InitializeService(DataServiceConfiguration config)
    {
        config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        config.SetEntitySetAccessRule("Tables", EntitySetRights.All);
    }
}

Because each table in the SQL database has a different set of columns, I am looking for a way to add properties to the Table class dynamically so it can represent the shape of the database table as it exists at the time of the query.

For example, assuming the database contains a table called Population, I’d like to be able to support the following OData query:

http://localhost/WcfDataService.svc/Tables('Population')?$filter=Code eq 'CA'

where Code is a char(2) column containing the US state codes.

So far, any attempts to use either an ExpandoObject (instead of the Table class) or having the Table class derive from DynamicObject have failed to create a workable OData feed, resulting the following ‘Request Error’:

The exception message is ‘Internal Server Error. The type ‘ServiceLibrary.Table’ is not supported.’

with the stack trace showing the exception being thrown inside

System.Data.Services.Providers.ReflectionServiceProvider.BuildHierarchyForEntityType

Is there a way to create a Table class that exposes properties (representing the columns of the corresponding database table) dynamically that can be used by a WCF Data Service to browse a SQL database?

  • 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-21T14:15:49+00:00Added an answer on May 21, 2026 at 2:15 pm

    The OData Provider Toolkit contains a sample implementation of a R/W Untyped Data Provider which can easily be modified to return metadata and table data.

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

Sidebar

Related Questions

I have a simple WCF Data Services service and I want to expose a
I have a database schema (MySql) exposed as a data/OData service that is queried
I have a WCF service and I want to expose it as both a
I have an existing web service and I want it to expose 2 MEX
I created a minuscule WCF service as a proof of concept. I eventually want
I am creating a service REST type using WCF in C# Visual Studio 2010
I want expose WebClient.DownloadDataInternal method like below: [ComVisible(true)] public class MyWebClient : WebClient {
I already have an enterprise Java EE application. I want expose some of the
I want to expose a webmethod that will take in a username and password
I want to expose my google calendar in my web app, and through one

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.