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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:42:12+00:00 2026-06-17T20:42:12+00:00

Lets say I have a WebGet method: [WebGet] public IQueryable<State> GetStatesStartingWithLetter(string letter) { return

  • 0

Lets say I have a WebGet method:

[WebGet]
public IQueryable<State> GetStatesStartingWithLetter(string letter)
{
     return CurrentDataSource.States.Where(s => s.Name.Substring(0, 1).Equals(letter.Substring(0, 1),
            StringComparison.InvariantCultureIgnoreCase)).OrderBy(s => s.Name);
}

I can consume it in a browser like so:

http://localhost:55576/WcfDataService.svc/GetStatesStartingWithLetter?letter='a'

However, what do I have to do in an MVC3 controller to call the method? I have added the service reference and I can use the context without a problem. The code below spits a list of states out to the screen at the /Controller/States URL.

public ActionResult States()
{
    MyDbContext ctx = new MyDbContext(new Uri("http://localhost:55576/WcfDataService.svc/"));

    var temp = from state in ctx.States
               select state;

    return View(temp);
}

I don’t see any EASY way to just call the WebGet method though, its not exposed on the service as I would expect it to be. Am I missing something? I can get the results by doing this:

public ActionResult States()
{
    WhelenDbContext ctx = new WhelenDbContext(new Uri("http://localhost:55576/WcfDataService.svc/"));

    var temp = ctx.Execute<State>(new Uri("http://localhost:55576/WcfDataService.svc/GetStatesStartingWithLetter?letter='a'"));

    return View(temp);
}

..but that seems a bit ridiculous. Any suggestions are much appreciated.

  • 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-17T20:42:13+00:00Added an answer on June 17, 2026 at 8:42 pm

    The “add service reference” functionality doesn’t recognize service operations (i.e., methods declared with [WebGet] on the service). You can use either ctx.Execute<T>() (like you have) or ctx.CreateQuery<T>(), but neither are the strongly-typed solution I think you were hoping for.

    For more information, see this page.

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

Sidebar

Related Questions

Lets say I have a class Public Class Person Public Name As String Public
Lets say I have object Tom which has class Person. Class Person String Name
lets say I have the following public class A { private string _someField; public
Lets say I have this extention method: public static bool HasFive<T>(this IEnumerable<T> subjects) {
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have many bean properties like this: <property name=posture> <list> <value>Lordosis</value> <value>Kyphosis</value>
lets say i have a table named cars{ 'id','name','brand_id', } and another table brand{
Lets say I have a configuration: <bean id=batchJobProperties class=org.springframework.beans.factory.config.PropertyPlaceholderConfigurer> <property name=locations> <list> <value>first.properties</value> <value>second.properties</value>
Lets say we have a program which contains such classes: public interface AbstractItem {
Lets say I have this amputated Person class: class Person { public int Age

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.