1

私が以下を持っている場合(簡潔にするために省略)

public class TempCartMap : ClassMap<TempCart>
{
   Id(x => x.Id).GeneratedBy.Identity();
   Map(x => x.Products); // < This one
}

[Serializable]
public class TempCart {

  public TempCart(){
    Products = new List<int>();
  }

  public virtual IList<int> Products { get; set; }

}

私は(http://www.philliphaydon.com/2012/06/using-nhibernate-with-servicestack/)と(http://www.philliphaydon.com/2012/03/ormlite-blobbing-doneを見てきました-with-nhibernate-and-serialized-json/ ) しかし、上記のように NHibernate で列をシリアライズおよびデシリアライズするための、より短く、シンプルで、高速な方法はありますか。新しい IUserType クラスなどを作成するのはやり過ぎのようです。

4

1 に答える 1

1

Products-list を別のテーブルとして保存することもできます。

public class TempCartMap : ClassMap<TempCart>
{
    Id(x => x.Id).GeneratedBy.Identity();

    HasMany(x => x.Products)
        .Element("product_number")
        .KeyColumn("temp_cart_id")
        .Table("temp_cart_products")
    ;
}

質問を明確にするために、これが望ましくない理由はありますか?

于 2012-07-09T12:56:22.237 に答える