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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:52:31+00:00 2026-06-01T07:52:31+00:00

For a given entity set, say, WHO_TYPES, I want to limit the columns to

  • 0

For a given entity set, say, WHO_TYPES, I want to limit the columns to the ID and the WHO_TYPE_NAME.

The entity set itself is exposed, via:

config.SetEntitySetAccessRule("WHO_TYPES", EntitySetRights.AllRead);

… so I can’t see how to do this when setting the entity/table access rules. Is it possible to write a QueryInterceptor to accomplish this? If so, how?

Another attempt I have made is to write a custom method that references a custom object:

[DataServiceKey("MY_WHO_TYPES")]
public partial class MY_WHO_TYPES
{
    public MY_WHO_TYPES() { }

    public int MY_WID { get; set; }
    public string MY_WNAME { get; set; }
}

My custom method:

    [WebGet]
    public IQueryable<MY_WHO_TYPES> GetWhoTypesCustom()
    {
        var whoCustom = from w in this.CurrentDataSource.WHO_TYPES
                        select new MY_WHO_TYPES() { MY_WID = w.ID, MY_WNAME = w.WHO_TYPE_NAME };

        return whoCustom.AsQueryable<MY_WHO_TYPES>();
    }

With this attempt, I get the following error message:

Unable to load metadata for return type 'System.Linq.IQueryable`1[DAL.Models.MY_WHO_TYPES]' of method 'System.Linq.IQueryable`1[DAL.Models.MY_WHO_TYPES] GetWhoTypesCustom()'.

I’m feeling some sort of repository pattern coming up in a response, but I’m hoping this could be simpler.

The suggestion of using a Tuple sounds good, but I’m not quite sure how to implement it or what the return type would be:

select new { Tuple<int, string> (w.ID, w.WHO_TYPE_NAME)};  // error: Invalid anonymous type member declarator.  Anonymous type members must be declared with a memeber assignment...

Next I tried simply returning an anonymous type:

    [WebGet]
    public IQueryable GetWhoTypesCustom()
    {
        var whoCustom = from w in this.CurrentDataSource.WHO_TYPES
                        select new { w.ID, w.WHO_TYPE_NAME };
        return whoCustom;
    }

The problem with this is that I get an error indicating the IQueryable type is not defined.

  • 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-01T07:52:33+00:00Added an answer on June 1, 2026 at 7:52 am

    The simplest way to do this is to use stored procedures instead of the actual entities themselves.

    This involves creating a complex type from the sproc. Define the columns that you want to be returned in the sproc and create a complex object when creating your entities.

    From the *.edmx view:

    Right-click / Add / Function Import
    Select the sproc
    Give it a Function Import Name
    Click Get Column Information
    Click Create New Complex Type - give it a name (by default looks like [Function Import Name]_Result
    

    That should work, but it seems there is some issue when consuming the service, where navigating to the URL in a browser shows data, but when consuming it in an application, an error is seen in the service trace log: Configuration evaluation context not found. This is addressed in another question.

    However, if it’s a 1:1 field mapping in the sproc to one of the entities, in the steps above, instead of selecting a new complex type, select Entities and the matching entity and this will work fine in both cases (URL navigation an consumption).

    class Program
    {
        static void Main(string[] args)
        {
            DataServiceContext context = new DataServiceContext(new Uri("http://localhost:50100/DataService1.svc/"));
            IEnumerable<WHO_TYPES> result = context.Execute<WHO_TYPES>(new Uri("http://localhost:50100/DataService1.svc/GetDataWhoTypesSproc"));
            foreach (WHO_TYPES w in result)
            {
                Console.WriteLine(w.ID + "\t" + w.WHO_TYPE_NAME + "\t" + w.CREATED_DATE);
            }
    
            Console.Read();
        }
    }
    

    The issue found (unable to return complex types) seems to be what the root cause of this issue, and is more accurately addressed here.

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

Sidebar

Related Questions

Given an Entity Data Model (EDMX) with Code Generation Strategy set to None, how
Given domain model... public class Entity { public int Id { get; set; }
Given a simple entity relationship: @Entity public class Single { @OneToMany public Set<Multiple> multiples;
Given the following entity (some columns omitted from this long definition for brevity): @Table(name
Given a small set of entities (say, 10 or fewer) to insert, delete, or
Given a set of entity ids, how can you efficiently delete the entities to
How can I give set foreign key value field in Entity Framework. I have
Is it possible to do mass updates on a given entity in Core Data?
If given an entity with a DateTime as a string, what are my options
I need to get the current context given an entity I found this old

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.