I have 2 objects:
public class Authors
{
public virtual int Id { get; set; }
public virtual string FirstName { get; set; }
public virtual string LastName { get; set; }
public virtual IList<Tags> Tags { get; set; }
}
public class Tags
{
public virtual int Id { get; set; }
public virtual string TagMark { get; set; }
public virtual IList<Authors> Authors { get; set; }
}
and mappings for them
public class AuthorsMap : ClassMap<Authors>
{
public AuthorsMap()
{
Id(x => x.Id);
Map(x => x.FirstName)
.Length(100)
.Not.Nullable();
Map(x => x.LastName)
.Length(100)
.Not.Nullable();
HasManyToMany(x => x.Tags);
}
}
public class TagsMap : ClassMap<Tags>
{
public TagsMap()
{
Id(x => x.Id);
Map(x => x.TagMark)
.Length(100)
.Not.Nullable();
HasManyToMany(x => x.Authors)
.Cascade.All().Inverse();
}
}
But when I want to add new tags to existing author, I don't get anything. Even error is not thrown and, of course tag is not added to relationship table with authors.
for example:
using (var trans.....) {
author.Tags.Add(tagobject)
trans.Commit()
}
while tagobject and author are obtained earlier. I also tried to add like session.SaveOrUpdate(author), but doesn't work... HEELP!