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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:01:26+00:00 2026-05-23T01:01:26+00:00

I have this following piece of code: public TimestampedRowStorage GetTimestampedRowStorage(string startTime, string endTime, long

  • 0

I have this following piece of code:

public TimestampedRowStorage GetTimestampedRowStorage(string startTime, string endTime, long trendSettingID, int? period)
    {
        var timestampedList = (from t in dataContext.TrendRecords
                                     where t.TrendSetting_ID == trendSettingID
                                     select t).ToList();

        return new TimestampedRowStorage
        {
            TimestampedDictionary = timestampedList.ToDictionary(m => m.Timestamp,
                m => (from j in dataContext.TrendSignalRecords
                      where j.TrendRecord_ID == m.ID
                      select j).ToDictionary(p => p.TrendSignalSetting.Name,
                p => (double?)p.Value))
        };
    }

But I always get the following exception:

There is already an open DataReader
associated with this Connection which
must be closed first.

Here is the stack trace:

[MySqlException (0x80004005): There is
already an open DataReader associated
with this Connection which must be
closed first.]
MySql.Data.MySqlClient.MySqlCommand.CheckState()
+237 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior
behavior) +146
MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) +47
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior
behavior) +10
System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand
entityCommand, CommandBehavior
behavior) +443

[EntityCommandExecutionException: An
error occurred while executing the
command definition. See the inner
exception for details.]
System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand
entityCommand, CommandBehavior
behavior) +479
System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext
context, ObjectParameterCollection
parameterValues) +736
System.Data.Objects.ObjectQuery1.GetResults(Nullable1
forMergeOption) +149
System.Data.Objects.ObjectQuery1.Execute(MergeOption
mergeOption) +31
System.Data.Objects.DataClasses.EntityReference
1.Load(MergeOption
mergeOption) +148
System.Data.Objects.DataClasses.RelatedEnd.Load()
+37 System.Data.Objects.DataClasses.RelatedEnd.DeferredLoad()
+8032198 System.Data.Objects.DataClasses.EntityReference1.get_Value()
+12 Nebula.Models.TrendSignalRecord.get_TrendSignalSetting()
in C:\Users\Bruno
Leonardo\documents\visual studio
2010\Projects\Nebula\Nebula\Models\SmgerDataModel.Designer.cs:2528
Nebula.Models.Trends.TrendRepository.<GetTimestampedRowStorage>b__b(TrendSignalRecord
p) in C:\Users\Bruno
Leonardo\documents\visual studio
2010\Projects\Nebula\Nebula\Models\Trends\TrendRepository.cs:229
System.Linq.Enumerable.ToDictionary(IEnumerable
1
source, Func2 keySelector, Func2
elementSelector, IEqualityComparer1
comparer) +226
System.Linq.Enumerable.ToDictionary(IEnumerable
1
source, Func2 keySelector, Func2
elementSelector) +54
Nebula.Models.Trends.TrendRepository.b__a(TrendRecord
m) in C:\Users\Bruno
Leonardo\documents\visual studio
2010\Projects\Nebula\Nebula\Models\Trends\TrendRepository.cs:227
System.Linq.Enumerable.ToDictionary(IEnumerable1
source, Func
2 keySelector, Func2
elementSelector, IEqualityComparer
1
comparer) +240
System.Linq.Enumerable.ToDictionary(IEnumerable1
source, Func
2 keySelector, Func2
elementSelector) +53
Nebula.Models.Trends.TrendRepository.GetTimestampedRowStorage(String
startTime, String endTime, Int64
trendSettingID, Nullable
1 period) in
C:\Users\Bruno
Leonardo\documents\visual studio
2010\Projects\Nebula\Nebula\Models\Trends\TrendRepository.cs:224
Nebula.Models.Trends.TrendRepository.GetTrendSettingContainer(String
startTime, String endTime, Int64
unitID, Int64 plantID, Int64
trendSettingID, GridSortOptions
gridSortOptions, Nullable1 page,
Nullable
1 recordsPerPage, Nullable1
period, Int64[] trends, Nullable
1
allTrends) in C:\Users\Bruno
Leonardo\documents\visual studio
2010\Projects\Nebula\Nebula\Models\Trends\TrendRepository.cs:206
Nebula.Controllers.GeneratingUnitController.TrendSettings(Int64
id, Int64 plantID, Int64
trendSettingID, String startTime,
String endTime, Nullable1 page,
Nullable
1 recordsPerPage,
GridSortOptions options, Nullable1
period, Int64[] trends, Nullable
1
allTrends) in C:\Users\Bruno
Leonardo\documents\visual studio
2010\Projects\Nebula\Nebula\Controllers\GeneratingUnitController.cs:148
lambda_method(Closure , ControllerBase
, Object[] ) +543

Can you guys help me out?

  • 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-23T01:01:27+00:00Added an answer on May 23, 2026 at 1:01 am

    The error is probably because you are trying to access the database while you are accessing the database.
    You should try to separate the two Linq expressions.
    Maybe put something like this:

    var TimestampedList = (from t in dataContext.TrendRecords
                                             where t.TrendSetting_ID == trendSettingID
                                             select t).ToList();
    TimestampedDictionary = timestampedList.ToDictionary(m => m.Timestamp,
                        m => (from j in dataContext.TrendSignalRecords
                              where j.TrendRecord_ID == m.ID
                              select j).ToDictionary(p => p.TrendSignalSetting.Name,
                        p => (double?)p.Value))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code in my DataModel.cs class: public User ValidateUser(string
IE what happens if you have this following piece of code? int mean(const vector<int>
I have the following piece of code: public void AddHash( int val ) {
I have following piece of code: class Test{ private: int id; public: Test(int v):id(v)
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie
I have following piece of code: public void ProcessRequest (HttpContext context) { context.Response.ContentType =
I have the following piece of code: class Foo { public Foo() { Bar
I have this piece of code from GWT in Action: public void processOperator(final AbstractOperator
I have this piece of code: @RequestMapping(value = /test.json, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public
I have a piece of code like the following: public class ActivityHelper { public

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.