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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:53:14+00:00 2026-06-12T09:53:14+00:00

I have a simple WCF Data Service set up. I went with a Linq-to-SQL

  • 0

I have a simple WCF Data Service set up. I went with a Linq-to-SQL solution.

public class MyDataService : DataService<SomeDataContext>
{
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.SetEntitySetPageSize("*", 20);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
        }

Since I’m using Linq, I had to do add partial classes for the keys

[DataServiceKey("MessageId")]
public partial class Message
{
}

[DataServiceKey("UserId")]
public partial class User
{
}

…

So I want to add a primitive method to get special users who have sent a message. Since Linq aggregate operators, such as count, are not supported, I figured a decent workaround would be to create a read-only resource endpoint for the count.So I added a method

   [WebGet]
    public int NumSpecialUsers()
    {
        var context = new SomeDataContext();
        int numUsers =
            context.Messages
            .Where(x => x.special == true && x.UserId != null)
            .Select(x => x.UserId)
            .Distinct()
            .Count();

        return numUsers;
    }

and added the necessary configuration to InitializeService()

    config.SetServiceOperationAccessRule("NumUsers", ServiceOperationRights.AllRead);

I can successfully call the method via localhost:1234/MyDataService.svc/NumSpecialUsers , however there’s no discovery for this method in localhost:1234/MyDataService.svc.
This doesn’t seem right. By not showing up in localhost:1234/MyDataService.svc , that would violate REST, because it would mean an undiscoverable endpoint. Which also means that when you use Visual Studio to create an OData Linq proxy, it doesn’t show the method there, either.

I’m neither a REST | OData | WCF Data Services expert, so if anyone has thoughts about this, I’d love to hear them. I am just beginning my adventure into OData and WCF Data Services and I would like to take a good approach to things. Many Thanks.

  • 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-12T09:53:15+00:00Added an answer on June 12, 2026 at 9:53 am

    The problem is that for service operations to show in the service document, what will be the url look like if the service operations take parameters?

    We had a choice of showing none of the service operations or showing only service operations which take no parameters – we erred on the side of consistency and made the former choice.

    If you still think it would be better to show only service operations which take no parameters, then i would love to hear the argument and even make the change if we get a lot of feedback for this feature.

    Thanks
    Pratik

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

Sidebar

Related Questions

I have a WCF service that uses LINQ to SQL for its data layer.
I have a simple WCF Data Services service and I want to expose a
I have a simple class, let's say Team and I expose a WCF service
I have a simple WCF service: public Order[] GetOrdersByStatus(int statusid) { OrderService os =
I'm new to WCF data services. I have a quite simple data model. Some
Hi I have built a simple WCF application I am using to query data
I have a simple WCF service hosted in IIS7 using the HTTP protocol. The
I have a simple WCF Web service. It's hosted on IIS under the default
We have a simple WCF service that is tagged with InstanceContextMode = Single and
I have a very simple WCF service running that has a single method that

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.