2
Cart
{
 CompositeId().KeyProperty(x => x.CART_ID, "CART_ID").KeyProperty(x => x.COMM_CD, "COMM_CD");
 References(x => x.Product, "COMM_CD");
}

当我尝试将购物车对象保存到数据库中时,我收到了超出范围的异常。我认为这是因为我有两个 COMM_CD 属性。有没有办法解决这个问题?

谢谢

4

1 回答 1

2

您需要使用KeyReference而不是KeyProperty

CompositeId()
    .KeyProperty(x => x.CART_ID, "CART_ID")
    .KeyReference(x => x.Product, "COMM_CD");
于 2012-07-13T01:19:32.967 回答