有这样的型号
public class Product // Товар
{
public int Id { get; set; }
public string Name { get; set; }
public int CategoryId { get; set; }
public ProductCategory Category { get; set; }
}
public class ProductCategory // Категория товаров
{
public int Id { get; set; }
public string Name { get; set; }
public List<Product> Products { get; set; } = new List<Product>();
}
我需要大规模改变产品null
类别CategoryId = 1
我正在尝试这样做
await _context.Products.Where(w => w.Id == 1)
.ExecuteUpdateAsync(s=>s.SetProperty(u=>u.Category, u=>u.Category = null));
但我收到一个错误
An expression tree may not contain an assignment operator
我怎么解决这个问题?