Jeff
Jeff

Reputation: 355

No Response from WCF with Entity Framework objects

Ok, i have the following object I pass back when someone calls "Authenticate" on my WCF Service (using http).

[DataContract]
public sealed class SecurityContext
{
    private Guid _tolken;
    private User _user;
    private ICallbackContract _callbackContract;

    [IgnoreDataMember]
    public ICallbackContract CallbackContract
    {
        get { return _callbackContract; }
    }

    [DataMember]
    public User User
    {
        get { return _user; }
        set { _user = value; }
    }

    [DataMember]
    public Guid Tolken
    {
        get { return _tolken; }
        set { _tolken = value; }
    }

    public SecurityContext(Guid tolken, User user, ICallbackContract callbackContract)
    {
        Asserter.IsNotNullArgument(tolken, "tolken");
        Asserter.IsNotNullArgument(user, "user");
        Asserter.IsNotNullArgument(callbackContract, "callbackContract");

        _tolken = tolken;
        _user = user;
        _callbackContract = callbackContract;
    }
}

For some reason, when i make the Async call, it times out and I never get a response, but when i comment out the User object (which is a Entity Framework object) it works fine.

Anyone ever experience this before?

Upvotes: 1

Views: 353

Answers (2)

Jeff
Jeff

Reputation: 355

Ok, so i figured out what the problem was. Apparently the entity model is set to Lazy load by default. This was causing issues with the data being HUGE when it was sent to the client...

I solved the issue by doing this during the entity model creation...

_entities.ContextOptions.LazyLoadingEnabled = false;

Upvotes: 2

netmajor
netmajor

Reputation: 6585

is User class have DataContract attribute?

Upvotes: 0

Related Questions