我正在尝试使用 NHibernate 和 Fluent NHiberate。我写了两个类如下:
public class Product
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual decimal Price { get; set; }
}
public class ShoppingCart
{
public virtual int Id { get; set; }
public IList<Product> Products { get; set; }
public decimal CartTotal
{
get { return Products.Aggregate(0m, (c,x)=> c + x.Price; ); }
}
public ShoppingCart()
{
Products = new List<Product>();
}
}
我想映射Product,ShoppingCart但我不希望任何ShoppingCart.Id作为Products表中的键。如何使用定义地图Fluent NHibernate?
PS:-我尝试过映射Category和SucCategory使用自引用类别。但我无法解决ShoppingCart问题Product。我也想用MS Sql Server CE 4.0.