簡體   English   中英

WCF服務未返回虛擬屬性ServiceProvider

[英]WCF Service not returning virtual property ServiceProvider

public class Account
{
    [DataMember]
    public int AccountId { get; set; }
    [DataMember]
    public string Email { get; set; }
    [DataMember]
    public string Password { get; set; }
    [DataMember]
    public string ConfirmPassword { get; set; }

    [ForeignKey("ServiceProvider")]
    [DataMember]
    public int ServiceProviderId { get; set; }
    [DataMember]
    public virtual ServiceProvider ServiceProvider { get; set; }
}

當嘗試

this.context.Configuration.LazyLoadingEnabled = false;
this.context.Configuration.ProxyCreationEnabled = false;

它將ServiceProvider返回為null

將急切加載與Include方法一起使用:

using System.Data.Entity;
//...
context.Accounts.Include(x => x.ServiceProvider).Where(...)

請參閱本主題以進行澄清: 首先關閉針對EF代碼的CTP5的ProxyCreationEnabled的不利之處

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM