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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:30:41+00:00 2026-05-25T11:30:41+00:00

In my app I perform an entityquery. If I use SQL profiler, catch the

  • 0

In my app I perform an entityquery. If I use SQL profiler, catch the SQL query that is generated, and run it manually, it gives the results I expect.
For instance

Val     Date
68  2011-05-31 00:00:00.000
48  2011-05-30 00:00:00.000
92  2011-05-29 00:00:00.000
52  2011-05-28 00:00:00.000
32  2011-05-27 00:00:00.000
32  2011-05-26 00:00:00.000
52  2011-05-25 00:00:00.000
81  2011-05-24 00:00:00.000

If I stick a breakpoint in my code and look at what the LoadOperation.Entities contains, I notice that when the ‘Val’ figure for an entry has already appeared (I.E like 52 above), then the LoadOperation.Entities collection uses the data from the previous entry (with a value of 52), rather than the actual date.
So in the data above, my LoadOperation.Entities looks like (note that dates are now repeated, seemingly because the ‘Vals’ have occurred previously)

68  2011-05-31 00:00:00.000
48  2011-05-30 00:00:00.000
92  2011-05-29 00:00:00.000
52  2011-05-28 00:00:00.000
32  2011-05-27 00:00:00.000
32  2011-05-27 00:00:00.000
52  2011-05-28 00:00:00.000
81  2011-05-24 00:00:00.000

Does anyone know why this is happening?

My EntityQuery looks like

    var appDataQuery = context.GetVwKeyDatasQuery().Where(d => d.KPIDate <= OverViewDate && d.GELID == GelID && d.ClockworkID == ClockWorkID).OrderByDescending(d => d.KPIDate);

And this generates the correct T-SQL, which when executed in SQL Query Analyzer returns the correct values.

The rest of the code is

    LoadOperation lo = context.Load<vwKeyData>(appDataQuery);
    lo.Completed += new EventHandler(LoadOperation_Completed);

The EventHandler is

    public void LoadOperation_Completed(object sender, EventArgs e)
    {
    LoadOperation<vwKeyData> histResults = sender as LoadOperation<vwKeyData>;
    int _count = 0;
    foreach (vwKeyData v in histResults.Entities)
    {.......

By this point histResults.Entities is already incorrect. Any help would be appreciated as this is screwing up some charting stuff i’m working on.

Thanks

M

  • 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-25T11:30:42+00:00Added an answer on May 25, 2026 at 11:30 am

    Answer as above. Each column that is required to uniquely idenitfy a row, should be set as an Entity Key in the model.

    (Right click the column in the model designer and select Entity Key).

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

Sidebar

Related Questions

I'm building a app that needs to perform calculations on money. I wonder how
I have a small WinForms app that utilizes a BackgroundWorker object to perform a
I have an app that struggles to perform well on iOS 5 running on
I have an app with a widget that loads an activity to perform an
My iPad app uses a popover to perform some searching. The search results are
I have a WPF app that from time to time needs to perform a
I am trying to create an app that will perform actions on specific times
I'm building an app that uses phone numbers to perform different tasks, and recently
I am writing an app in cakephp that will perform scheduled searches for users
I have an ASP.NET web app where I use an ado sql connection to

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.