Ignore this.  This is a perfect case of "When you hear hoof steps,
think horses not zebras"

I was reusing the same object, so of course fluent was doing exactly
what I told it to.

No bug, just a mistake


On Mar 9, 10:06 am, rohmer <roh...@yahoo.com> wrote:
> What I need to do is rather simple, but I seem to be missing
> something.
>
> I have 2 objects in my example, a configuration object and mediatype
> object.  When I write out the objects, I only get the last child.  Ive
> tried OneToMany, References, and many permutations of saving and
> commiting, but to no use.
>
> This is in Sql Compact 3.5 sp 2
>
> One configuration maps to 0-X mediatypes.  Here are my entities:
>
> Parent
>  public class CConfigEntity
>     {
>         public virtual IList<CMediaFileTypesEntity> MediaTypes { get;
> set; }
>
>         public CConfigEntity()
>         {
>             FileSystems = new List<CFileSystemEntity>();
>             MediaTypes = new List<CMediaFileTypesEntity>();
>         }
>
>         public virtual void AddMediaType(CMediaFileTypesEntity
> mediaType)
>         {
>             MediaTypes.Add(mediaType);
>         }
>     }
>
> Child
>     public class CMediaFileTypesEntity
>     {
>         public virtual Guid ID { get; private set; }
>
>         public virtual string Description { get; set; }
>
>         public virtual string Extension { get; set; }
>     }
>
> Here are the Maps:
>
>     public class CConfigMap : ClassMap<CConfigEntity>
>     {
>         public CConfigMap()
>         {
>             Table("Configuration");
>             Id(x =>
> x.ID).GeneratedBy.GuidComb().UnsavedValue("00000000-0000-0000-0000-00000000­0000");
>            HasMany<CMediaFileTypesMap>(x =>
> x.MediaTypes).Cascade.All();
>         }
>     }
>
>     public class CMediaFileTypesMap : ClassMap<CMediaFileTypesEntity>
>     {
>         public CMediaFileTypesMap()
>         {
>             Table("MediaFileTypes");
>             Id(x => x.ID, "ID").GeneratedBy.GuidComb();
>             Map(x => x.Description);
>             Map(x => x.Extension);
>         }
>     }
>
> And here is the code that adds them:
>
>             for (int i = 0; i < Extensions.Length / 2; i++)
>             {
>                 tmp.Description = Extensions[i, 1];
>                 tmp.Extension = Extensions[i, 0];
>                 session.Save(tmp);
>                 configEntity.AddMediaType(tmp);
>             }
>             session.Save(configEntity);
>             transaction.Commit();
>             transaction.Dispose();
>             session.Close();
>         }

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to