我要将列表中的一些产品添加到OrderRows表中,但是当我开始输入db时。 ??? Intellisens没有给med选择OrderRows类的任何选项,然后继续添加....我做错了什么?
var listShoppingCart = Session["ShoppingCart"] as List<Products>; // Cast
foreach (var item in listShoppingCart)
{
var productFromList = new OrderRows
{
ProductID = item.ID,
OrderID = orderId,
Price = item.Price
};
//db. ????
//db. ?? .Add(productFromList);
//db.SaveChanges();
这些是类,也许它们之间存在一些错误?
public class Orders
{
public int ID { get; set; }
public DateTime Orderdate { get; set; }
public int CustomersID { get; set; }
public virtual Customers Customers { get; set; }
public virtual ICollection<OrderRows> OrderRows { get; set; }
}
public class OrderRows
{
public int ID { get; set; }
public int ProductID { get; set; }
public int OrderID { get; set; }
public float Price { get; set; }
public virtual Orders Orders { get; set; }
}