简体   繁体   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; }
}

When tried with 当尝试

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

it return ServiceProvider as null 它将ServiceProvider返回为null

Use eager loading with Include method: 将急切加载与Include方法一起使用:

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

See this topic for clarification: What are the downsides to turning off ProxyCreationEnabled for CTP5 of EF code first 请参阅本主题以进行澄清: 首先关闭针对EF代码的CTP5的ProxyCreationEnabled的不利之处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM