数据库对应EFCore操作

数据库对应EFCore操作

目录
  • 数据库对应EFCore操作
  • 1,查某个id在某个集合被包含的数据
  • 2.查某id集合不被某集合包含的数据

1,查某个id在某个集合被包含的数据

例如: 查 Id 在ids里的结合

            //实现的sql是实体Id in ids,也就是ids跟Id 两个集合的交集
            var _ainfcfgs = await _ainfcfgServices.GetListAsync(x => ids.Contains(x.Id));

2.查某id集合不被某集合包含的数据

例如:查Id不被countryUpdateCityIds包含的城市

 var countryUpdateCityIds = countryUpdateResource.Cities.Select(x => x.Id).ToList();
 var removedCities = country.Cities.Where(c => !countryUpdateCityIds.Contains(c.Id)).ToList();

你可能感兴趣的:(数据库对应EFCore操作)