This is a migrated thread and some comments may be shown as answers.

[Solved] WCF and Entity Framework with GridModel

0 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin
Top achievements
Rank 1
Kevin asked on 28 Oct 2011, 05:38 PM
I have an Entity Framework (Code First, 4.1) context that is used in a WCF service layer.  If I have the service set up this way:

public IEnumerable<Dto.PlanMember> GetPlanMembers() {
    var planMembers = from member in this.DataSource.PlanMemberDbSet.Take(10)
                select new Dto.PlanMember {
                      Id = member.Id,
                      FirstName = member.FirstName,
                      LastName = member.LastName
                };
 
    return planMembers;
}

The service works fine.  If I set it up like this, following the examples for grid binding via web services...
public GridModel GetPlanMembers(GridState state) {
    var planMembers = from member in this.DataSource.PlanMemberDbSet.Take(10)
                select new Dto.PlanMember {
                    Id = member.Id,
                    FirstName = member.FirstName,
                    LastName = member.LastName
                };
 
    return planMembers.ToGridModel(state);
}

It consistently get the exception:

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


This is a serialization issue.  For whatever reason the ToGridModel extension method isn't working properly with EFCF 4.1.  What can be done to fix this?
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Share this question
or