I'm running into a problem when I try to map component collections via attributes. It doesn't seem that the additional properties of the component get persisted. When I create the database with the SchemaTool the columns don't get created. Here are my two classes. What am I doing wrong?
Code:
[Class(Lazy = false)]
public class NewsItem : Entity
{
[Property(NotNull = true)]
public string Title { get; set; }
[Property(NotNull = true, Length = 8000)]
public string Body { get; set; }
private IList<NewsImage> images = new List<NewsImage>();
private DateTime publishDate = DateTime.Now;
[List(Lazy = false)]
[Key(1, Column = "NewsItemId")]
[Index(2, Column = "ImageOrder")]
[CompositeElement(3, ClassType = typeof(NewsImage))]
public IList<NewsImage> Images
{
get { return images; }
set { images = value; }
}
[Property(NotNull = true)]
public DateTime PublishDate
{
get { return publishDate; }
set { publishDate = value; }
}
[Property(NotNull = true)]
public bool Display { get; set; }
}
[Component]
public class NewsImage : Entity
{
[Property]
public string Caption { get; set; }
[Property()]
public string Filename { get; set; }
[Property()]
public int ImageOrder { get; set; }
public bool Equals(NewsImage obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return Equals(obj.Caption, Caption) && Equals(obj.Filename, Filename) && obj.ImageOrder == ImageOrder;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof (NewsImage)) return false;
return Equals((NewsImage) obj);
}
public override int GetHashCode()
{
unchecked
{
int result = (Caption != null ? Caption.GetHashCode() : 0);
result = (result*397) ^ (Filename != null ? Filename.GetHashCode() : 0);
result = (result*397) ^ ImageOrder;
return result;
}
}
}