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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:00:01+00:00 2026-06-01T20:00:01+00:00

When I return IEnumerable<ProgramRange> an exception is thrown: The underlying connection was closed: The

  • 0

When I return IEnumerable<ProgramRange> an exception is thrown:

The underlying connection was closed: The connection was closed unexpectedly.

The class ProgramRange looks like this:

[DataContract]
public partial class ProgramRange
{
    public ProgramRange()
    {
        this.GradeVariants = new HashSet<GradeVariant>();
    }

    [DataMember]
    public int ID { get; set; }
    [DataMember]
    public int Range { get; set; }
    [DataMember]
    public string Description { get; set; }

    [DataMember]
    public virtual ICollection<GradeVariant> GradeVariants { get; set; }
}

The collection only contains eight items, so I don’t think it’s the <dataContractSerializer maxItemsInObjectGraph="2147483647" /> which is often suggested.

When I fetch the data from the context I do .ToList() so it can’t be that:

 public IEnumerable<ProgramRange> GetAll()
    {
        using (Entities dbContext = new Entities())
        {
            return dbContext.ProgramRanges.ToList();

        }
    }

I’ve tried to add the ProgramRange class to the known types of your service in the implementation:

 [ServiceBehavior]
 [ServiceKnownType(typeof(ProgramRange))]
 public class ValidationService : IValidationService

I’ve tried returning several other things just to test: ProgramRange (works), IEnumerable<string> (works), List<ProgramRange> (does’t work)

I know there are several question on the subject here on stackowerflow and I tried a lot of suggestions, but I can’t get it to work.

Edit:

Here’s the GradeVariant class:

[DataContract]
public partial class GradeVariant
{
    public GradeVariant()
    {
        this.GradeVariantRules = new HashSet<GradeVariantRule>();
    }

    [DataMember]
    public int ID { get; set; }
    [DataMember]
    public int GradeTypeID { get; set; }
    [DataMember]
    public int ProgramRangeID { get; set; }
    [DataMember]
    public Nullable<int> ProgramID { get; set; }
    [DataMember]
    public Nullable<int> ApprenticeID { get; set; }
    [DataMember]
    public Nullable<int> Prefix { get; set; }
    [DataMember]
    public Nullable<bool> IV { get; set; }
    [DataMember]
    public string Description { get; set; }

    [DataMember]
    public virtual GradeType GradeType { get; set; }
    [DataMember]
    public virtual ProgramRange ProgramRange { get; set; }
    [DataMember]
    public virtual ICollection<GradeVariantRule> GradeVariantRules { get; set; }
}
  • 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-01T20:00:03+00:00Added an answer on June 1, 2026 at 8:00 pm

    I found the answer to my own question and here goes:

    The problem was that WCF was unable to serialize the circular reference that Entity Framework created when loading the referenced entities.

    To resolve this issue, simply put

    [DataContract(IsReference = true)]
    

    over the model class.

    It’s explained in detail here, http://www.binaryforge-software.com/wpblog/?p=129

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

Sidebar

Related Questions

1) public class Query<T> : IQueryable<T> ... { ... public IEnumerator<T> GetEnumerator() { return((IEnumerable<T>)this.provider.Execute(this.expression)).GetEnumerator();
class Foo { public static IEnumerable<int> Range(int start, int end) { return Enumerable.Range(start, end);
In Linq, extension methods like Where return an IEnumerable collection, but sorting methods like
When i complile the code class customer { Order getOrder; public IEnumerable<Order> MyOrders {
In the following collection: public class PersonsCollection : List<Person> How can I return an
I need to return an IEnumerable. Here is the working code: public IEnumerable<String> ReturnStudentsAsString(int
I have the following query: public IEnumerable<Team> GetAllTeamsWithMembers(int ownerUserId) { return _ctx.Teams .Include(x =>
I wish to do something like the following in my data layer public IEnumerable<{string,int}>
I am using ASP.MVC 1 to return an IEnumerable of objects (say, Cars): public
In my query i need to return IEnumerable but i dont know if this

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.