By default I want my Linq to SQL calls to include the child entities so I have LazyLoadingEnabled set to true. On a small subset of calls I want to return only the parent entities without the related child entities included. I tried setting LazyLoadingEnabled to false just before my linq query, and then setting it back to true just after but that had no effect.
Is there a way to achieve this?
Example Model:
public class UserProjectInternalMember
{
[Key, Column(Order = 0), ForeignKey("UserProject")]
public int UserProjectId { get; set; }
[Key, Column(Order = 1), ForeignKey("User")]
public string UserId { get; set; }
[Column(Order = 2), ForeignKey("UserProjectMembershipLevel")]
public int UserProjectMembershipLevelId { get; set; }
public virtual UserProject UserProject { get; set; }
public virtual ApplicationUser User { get; set; }
public virtual UserProjectMembershipLevel UserProjectMembershipLevel { get; set; }
[NotMapped]
public bool CanEdit { get; set; }
[NotMapped]
public bool CanRemove { get; set; }
}