[英]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.