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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:35:43+00:00 2026-05-20T08:35:43+00:00

I am writing a RIA service, which is also exposed using SOAP. One of

  • 0

I am writing a RIA service, which is also exposed using SOAP.
One of its methods needs to read data from a very big table.

At the beginning I was doing something like:

public IQueryable<MyItem> GetMyItems()
{
    return this.ObjectContext.MyItems.Where(x => x.StartDate >= start && x.EndDate <= end);
}

But then I stopped because I was worried about the performance.

As far as I understand MyItemsis fully loaded and “Where” just filters the elements that were loaded at the first access of the property MyItems. Because MyItemswill have really lots of rows, I don’t think this is the right approach.

I tried to google a bit the question but no interesting results came up.

So, I was thinking I could create a new instance of the context inside the GetMyItems method and load MyItems selectively. Something like:

 public IQueryable<MyItems> GetMyItems(string Username, DateTime Start, DateTime End)
    {
        using (MyEntities ctx = new MyEntities ())
        {
            var objQuery = ctx.CreateQuery<MyItems>(
                "SELECT * FROM MyItems WHERE Username = @Username AND Timestamp >= @Start AND Timestamp <= @End",
                new ObjectParameter("@Username", Username),
                new ObjectParameter("@Start", Start),
                new ObjectParameter("@End", End));

            return objQuery.AsQueryable();
        }
    }

But I am not sure at all this is the correct way to do it.

Could you please assist me and point out the right approach to do this?

Thanks in advance,
Cheers,
Gianluca.

  • 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-20T08:35:44+00:00Added an answer on May 20, 2026 at 8:35 am

    As far as I understand MyItemsis fully loaded and “Where” just filters the elements that were loaded at the first access of the property MyItems.

    No. That’s entirely wrong. Don’t fix “performance problems” until you actually have them. The code you already have is likely to perform better than the code you propose replacing it with. It certainly won’t behave in the way you describe. But don’t take my word for it. Use the performance profiler. Use SQL Profiler. And test!

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

Sidebar

Related Questions

I have a Silverlight 4 app which pulls entities down from a database using
Writing an iPhone app, and I'm getting my data from a REST API that
We are writing a WPF application using Entity framework (Silverlight with RIA services to
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
Writing a python program, and I came up with this error while using the
Writing an asynchronous Ping using Raw Sockets in F#, to enable parallel requests using
Writing my first app with CoreData. The book I'm using to guide me has
I'm trying to build a Silverlight App that accesses and presents data from a
Writing an application in Cocoa that will take input from the user, format it
I'm writing an application that has POCO Entity Framework data access on the server.

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.