例如学生类   
  public   class   Student   
  {   
  public   int   id;   
  public   string   name;   
  public   bool   sex;   
  public   DateTime   birthday;     }   
    
教师类
  public   class   Teacher
  {   
  public   int   id;   
  public   string   name;   
  public   bool   sex;   
  public   DateTime   birthday;   
  public   Student   student;
  } Student  stu1=new Student();
Teacher tea1=new Teacher();
tea1.id=....
.....
tea1.student=stu1;1.这个如果用NHibernate 的Seisson.save(tea1)时候,影射文件的student列 应该是什么类型??如果不能这样保存,序列化后  //   序列化为byte[]   
  MemoryStream   fs   =   new   MemoryStream();   
  byte[]   tmp   =   null;   
  BinaryFormatter   formatter   =   new   BinaryFormatter();   
  formatter.Serialize(fs,   student);   
  tmp   =   fs.ToArray();
  可以将将tmp作为bianry数据存到数据库2.影射文件的类型应该是 bianry?3.能不提供一个对象序列化后保存到SQLSEVER列子?

解决方案 »

  1.   

    1.这个如果用NHibernate 的Seisson.save(tea1)时候,影射文件的student列 应该是什么类型?? 
    这个调用student的序列化,再把他的哥哥元素解析直到所有内容都是value type而止
      

  2.   

    晕.没用过NHibernate 这东西.关注~
      

  3.   

    只用过很短一断时间的NHibernate,我觉得能否不把对象序列化,直接把对象的属性存入SQLSERVER?为何要多此一举呢?
      

  4.   

    谁提供个对象序列化后保存到SQLSEVER的列子嘛
      

  5.   

    <bag name="Student" inverse="true" lazy="true" cascade="delete">
          <key column="ID" />
          <one-to-many class="Student,namespace" />
        </bag>
    这是Teacher中Student在映射文件中的形式