我有两个班级:
public partial class User
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public User()
{
this.ActionLogs = new HashSet<ActionLog>();
this.Exceptions = new HashSet<Exception>();
this.OnlineUsers = new HashSet<OnlineUser>();
this.UserRoles = new HashSet<UserRole>();
}
public long Id { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public byte[] HashPass { get; set; }
public string LoweredUserName { get; set; }
public Nullable<long> BussinessPartnerId { get; set; }
public Nullable<long> BranchId { get; set; }
public Nullable<bool> IsSelected { get; set; }
public Nullable<long> CreatedBy { get; set; }
public Nullable<System.DateTime> CreationDate { get; set; }
public Nullable<System.DateTime> LastUpdateTime { get; set; }
public Nullable<long> LastUpdatedBy { get; set; }
public Nullable<bool> IsActive { get; set; }
public virtual ICollection<ActionLog> ActionLogs { get; set; }
public virtual BussinessPartner BussinessPartner { get; set; }
public virtual ICollection<Exception> Exceptions { get; set; }
public virtual ICollection<OnlineUser> OnlineUsers { get; set; }
public virtual ICollection<UserRole> UserRoles { get; set; }
}
和
public partial class BussinessPartner
{
public BussinessPartner()
{
this.PositonAppointments = new HashSet<PositonAppointment>();
this.Users = new HashSet<User>();
}
public long Id { get; set; }
public Nullable<long> PersonId { get; set; }
public Nullable<long> OrganizationId { get; set; }
public Nullable<long> EmployeeId { get; set; }
public Nullable<int> Type { get; set; }
public string FullName { get; set; }
public string Code { get; set; }
public Nullable<long> BranchId { get; set; }
public Nullable<bool> IsSelected { get; set; }
public Nullable<long> CreatedBy { get; set; }
public Nullable<System.DateTime> CreationDate { get; set; }
public Nullable<System.DateTime> LastUpdateTime { get; set; }
public Nullable<long> LastUpdatedBy { get; set; }
public Nullable<bool> IsActive { get; set; }
public virtual Employee Employee { get; set; }
public virtual Organization Organization { get; set; }
public virtual Person Person { get; set; }
public virtual ICollection<PositonAppointment> PositonAppointments { get; set; }
public virtual ICollection<User> Users { get; set; }
}
我为我的服务编写了这段代码:
[OperationContract]
public User DoWork()
{
var db = new AbanEntities();
db.Configuration.ProxyCreationEnabled = false;
var u = db.Users.Include("BussinessPartner").First();
return u;
}
问:在result =&gt;中你是用户,并且拥有一个名为BussinessPartner的属性,BussinessPartner字段具有值,BussinessPartner有一个名为&#39; User&#39;的属性,而且这个字段有价值,但我想要&#39;用户&#39;为空