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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:26:53+00:00 2026-06-03T23:26:53+00:00

When I retrieve all orders and their OrderDetails from ASP.NET MVC through WCF it

  • 0

When I retrieve all orders and their OrderDetails from ASP.NET MVC through WCF it throws error. till service it works fine, only when the call reaches out of service in this case MVC, it throws error:

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

  1. I am not using lazy loading

  2. I want to use same POCO class, don’t want separate create DataContract in WCF.

My code:

public class HomeController : Controller
{
    public ActionResult Index()
    {
        ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
        var allOrders = service.GetAllOrders();
        service.Abort();
        return View();
    }       
}

// WCF Service Method
public List<Order> GetAllOrders()
{
    List<Order> orders = null;
    using (NorthwindEntities context = new NorthwindEntities())
    {
        orders = context.Set<Order>().Include("Order_Details").AsEnumerable().ToList();
    }

    return orders;
}

public class Order
{
    public Order()
    {
        this.Order_Details = new HashSet<Order_Detail>();
    }

    public virtual ICollection<Order_Detail> Order_Details { get; set; }
  } 

public class Order_Detail
{
    public int OrderID { get; set; }
    public int ProductID { get; set; }
    public decimal UnitPrice { get; set; }
    public short Quantity { get; set; }
    public float Discount { 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-03T23:26:54+00:00Added an answer on June 3, 2026 at 11:26 pm

    thanks to Alex,

    it works after disabling ProxyCreationEnabled.

        public List<Order> GetAllOrders()
        {
            List<Order> orders = null;
    
            using (NorthwindEntities context = new NorthwindEntities())
            {
                context.Configuration.ProxyCreationEnabled = false;
                orders = context.Set<Order>().Include("Order_Details").AsEnumerable().ToList();
                context.Configuration.ProxyCreationEnabled = true;
    
            }
    
            return orders;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to retrieve all records from one table when there are no matches
I want to retrieve all documents from folder to it's subfolder and so on
I'm building a Facebook-like wall and wish to retrieve all updates from both the
I'd like to retrieve all local groups on my machine (Vista in a W2k3
How do I retrieve all elements after the first one not starting with a
I want to retrieve all objects (not DOM elements) of a given type created
I'm trying to retrieve all documents in a folder in google docs using the
I retrieve a list of ObjectId and I want to retrieve all object in
Is there any way to retrieve all friends in a particular network? For example,
I'm using the following code to retrieve all the HierarchicalRequirements and the child tasks,

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.