然后Indluce方法不带属性

时间:2019-04-13 09:20:19

标签: entity-framework include entity-framework-core

我想在我的班级中嵌套数据,并进行快速加载。但是当我调用ThenInclude()方法时,什么也没有出现。我该怎么办?

我不想获得SystemUser的商店并获取商店的详细信息。

这是我的课程:

public class SystemUser
    {
        public int Id { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }

        public virtual List<Store> Stores { get; set; }

        public SystemUser()
        {
            this.Stores = new List<Store>();
        }

    }

public class Store
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }

        public virtual CountryCode CountryCode { get; set; }
        public virtual Category Category { get; set; }

    }



 var user = await _context.SystemUser
                    .Include(x => x.Stores)

Here Category and CountryCode returns null. 

看来我应该做类似的事情

var user = await _context.SystemUser
                .Include(x => x.Stores)
                    .ThenInclude(a => a.Category /* Category doesnt appear in intellisense*/);

谢谢

0 个答案:

没有答案