entityframework导航属性筛选

时间:2021-11-01 05:41:55
                var user = db.UserInfos.FirstOrDefault(a => a.Id == );
//会在sql代码中生成Street = "上海"代码
var address1 = db.Entry(user).Collection(b => b.Address).Query().Where(p => p.Street == "上海" ).ToList();
//会把所有的Street的代码都取回内存,然后在内存在再访问
var address2 = user.Address.Where(p => p.Street == "上海").Count();