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

  • Home
  • SEARCH
  • 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 6790989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:47:32+00:00 2026-05-26T17:47:32+00:00

Following a couple different tutorials, I’ve been trying to build a Silverlight Business Application

  • 0

Following a couple different tutorials, I’ve been trying to build a “Silverlight Business Application” against a database I’ve created. I’ve found I have two problems. The one I’m asking about here is how to filter the query.

The query that is built in the DomainService is when using the VS2010 template is:

[EnableClientAccess]
public class ChargesService : LinqToEntitiesDomainService<ChargesEntities>
{
    public IQueryable<tblChargeCode> GetCharges()
    {
        return ObjectContext.tblChargeCodes.OrderBy(e => e.Chrgs_Code_01).Take(10);
    }
}

I’m trying to create another query against the same ObjectContext.tblChargeCodes. Pulling the entire table (30 columns by ~7k rows) creates a timeout error.

I can’t figure out how to do a select. I want to select Charge_Codes_01 and Bill_Description with a “starts with” type functionality (dynamic drop down search functionality). I’ve tried different variations of this without success. Something just isn’t clicking in my brain.

    public IQueryable<tblChargeCode> SearchCharges(string num)
    {
        var min = System.Convert.ToInt32(num.PadRight(7, '0'));
        var max = System.Convert.ToInt32(num.PadRight(7, '9'));
        return ObjectContext.tblChargeCodes
            .Select(e => e.Chrgs_Code_01, e.Chrgs_Code_01_Desc)
            .Where(e => e.Chrgs_Code_01 >= min && e.Chrgs_Code_01 <= max)
            .OrderBy(e => e.Chrgs_Code_01)
            .Take(10);
    }
  • 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-26T17:47:33+00:00Added an answer on May 26, 2026 at 5:47 pm

    (sorry for my bad english)

    The problem with you code is the “Select” – your method signature says that it must return a IQueryable of tblChargeCode, so you cannot return a projection. Here is two ways you can write your query:

    In the server:

    public IQueryable<tblChargeCode> SearchCharges(int min, int max, string description)
    {        
    
        return ObjectContext.tblChargeCodes            
            .Where(e => e.Chrgs_Code_01 >= min && e.Chrgs_Code_01 <= max)
            .Where(e => e.Bill_Description.StartsWith(description))
            .OrderBy(e => e.Chrgs_Code_01)
            .Take(10);
    }
    

    And call it on the client:

    context.Load(context.SearchChargesQuery(0, 9999999, "Bill"), (op) => 
    {
        //op.Entities has your entities loaded
    }, null);
    

    Or you can just leave the query on the server:

    public IQueryable<tblChargeCode> GetCharges()
    {
        return ObjectContext.tblChargeCodes.OrderBy(e => e.Chrgs_Code_01);
    }
    

    And call it from the client (it will filter on the server)

    context.Load(context.GetChargesQuery().Where(e => e.Chrgs_Code_01 >= 0 && e.Chrgs_Code_01 <= 9999999)
            .Where(e => e.Bill_Description.StartsWith("Bill"))
            .OrderBy(e => e.Chrgs_Code_01)
            .Take(10), (op) => 
            {
                //op.Entities has your entities loaded
            }, null);
    

    You also can use “Contains” instead of “StartsWith” in your query.

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

Sidebar

Related Questions

Recently I have started playing with jQuery, and have been following a couple of
I have couple resource DLLs that I currently load when application starts using following
I'm trying to use set_table_name to use one generic model on a couple different
I received the following error report from a couple of different users running Android
I have the following couple of C pre-processor macros for creating test functions: //
I'm following a couple of Pythone exercises and I'm stumped at this one. #
Following on from my question on using frozen Capistrano a couple of days back
From couple of days i am thinking of a following scenario Consider I have
Following recent hardware problems, I attempted to switch a couple of our websites to
I am using the following function to loop through a couple of open CDB

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.