Dear all,
I have problem with both cascadeDelete and EagerLoad. You find the corresponding table class definition at the bottom. To illustrate my problem I use the following dummy database entries:
- MainCat1
- SubCat1
- SubSubCat1
- SubSubCat2
- SubCat2
Problem regarding CascadeDelete:
- As you can see, I put attribute "[TableAttribute(CascadeDeletes=true)]" at the top of the table, and the attibute "[Dependent]" to the entityCollection. However, if I delete "SubCat1", both "SubSubCat1" and "SubSubCat2" are still in the database. Only the references to the parent (parentId) are deleted. I tried with both attributes or only with either of them.
Problem regarding EagerLoad:
- The query to find the parent categories is:
"Query query = new Query(Entity.Attribute<Category>("ParentCategoryId") == null);"
Using this query works as expected, except for the childCategories, which are not loaded eagerly. I tried putting the attribute "[EagerLoad]" to the entityCollection of childCategories as well as to the entityHolder of parentCategory. Neither worked.
Table definition:
[TableAttribute(CascadeDeletes=true)]
public partial class Category : Entity<int>
{
#region private members
#region values types
[ValidatePresence]
private string _Name;
private int? _ParentCategoryId;
#endregion
#region relations
//ManyToOne
[ReverseAssociation("ChildCategories")]
[EagerLoad]
public readonly EntityHolder<Category> _ParentCategory = new EntityHolder<Category>();
//OneToMany
[Dependent]
private readonly EntityCollection<Category> _ChildCategories =
new EntityCollection<Category>();
//ManyToMany
private readonly EntityCollection<WordListToCategory> _WordListToCategory =
new EntityCollection<WordListToCategory>();
private readonly ThroughAssociation<WordListToCategory, WordList> _Wordlists;
#endregion
#endregion
#region constructor
public Category()
{
_Wordlists = new ThroughAssociation<WordListToCategory, WordList>(_WordListToCategory);
}
#endregion
#region public properties
public string Name
{
get { return _Name; }
set { this.Set(ref _Name, value); }
}
public Category ParentCategory
{
get { return Get(_ParentCategory); }
}
public EntityCollection<Category> ChildCategories
{
get { return Get(_ChildCategories); }
}
public ThroughAssociation<WordListToCategory, WordList> WordLists
{
get { return Get(_Wordlists); }
}
#endregion
}