我的项目禁用了 LazyLoading。我想获取 Id = 1 的产品及其类别导航属性。但我只需要类别的 Id 和 Name 属性。这就是为什么我希望类别导航属性只有这两个字段。是否可以创建这样的查询?
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public dobule Price{ get; set; }
public string Description { get; set; }
public bool IsDeleted { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime ModifiedDate { get; set; }
public int CategoryId{ get; set; }
public Category Category{ get; set; }
}
public class Category
{
public …Run Code Online (Sandbox Code Playgroud)