我得到保存問題,當我使用Guid作爲標識符。可以 有人問我在這裏失蹤?我創建自己的GUID,所以我不希望它由數據庫生成。不會保存到數據庫與guid作爲ID流利nhiberate
注:我已經嘗試guid.combo映射到沒有任何成功。
public class Order
{
public virtual Guid Id { get; set; }
public virtual ICollection<OrderItem> OrderItems { get; set; }
public virtual User User { get; set; }
public virtual DateTime? CreateDate { get; set; }
public virtual DateTime? ShippedDate { get; set; }
public virtual string OrderStatus { get; set; }
public Order()
{
OrderItems = new Collection<OrderItem>();
}
public virtual void AddOrderItems(OrderItem orderItem)
{
orderItem.Order = this;
OrderItems.Add(orderItem);
}
}
OrderMap:
public OrderMap()
{
Id(x => x.Id).ColumnName("Id").GeneratedBy.Guid();
Map(x => x.CreateDate);
Map(x => x.ShippedDate);
Map(x => x.OrderStatus);
References(x => x.User);
HasMany(x => x.OrderItems).Cascade.All().Inverse().LazyLoad();
}
我會嘗試這THX產生的GUID。 – 2009-09-26 22:05:11
不確定關於分配,但當我改變保存和更新,而不是SaveOrUpdate它的工作。 – 2009-09-26 22:11:42