This question is locked. New answers and comments are not allowed.
Dear Telerik,
I am looking to use OpenAccess in a code first approach so I'm trying to use the fluent mapping API.I have two questions regarding associations.
1) In the following example, which is based on the documentation example, the CategoryId property seems double. You can get the Category Id by traversing the Category object requesting its id (ex: product.Category.ID). Is this property added for being able to enforce constraints or is it somehow needed by the openaccess infrastructure? If I remove it, the code still works.
2) A one-way optional association. I have a Site entity that has an optional dependency on a Template entity through the property Site.DefaultTemplate. Saving this association to the database works. Now I delete the Template entity and I wish this action also updates the property Site.DefaultTemplate to null. It's associated object is deleted after all. In the documenation I can only find information about Depends() for cascading deletes. I am basically looking for cascade on persist / update. Is there any such thing?
I am looking to use OpenAccess in a code first approach so I'm trying to use the fluent mapping API.I have two questions regarding associations.
1) In the following example, which is based on the documentation example, the CategoryId property seems double. You can get the Category Id by traversing the Category object requesting its id (ex: product.Category.ID). Is this property added for being able to enforce constraints or is it somehow needed by the openaccess infrastructure? If I remove it, the code still works.
public
abstract
class
Entity : IEntity
{
public
int
ID {
get
;
private
set
; }
}
public
class
Product : Entity
{
public
string
Name {
get
;
set
; }
public
int
CategoryId {
get
;
set
; }
public
Category Category {
get
;
set
; }
}
public
class
Category : Entity
{
public
Category()
{
this
.Products =
new
List<Product>();
}
public
string
Name {
get
;
set
; }
public
IList<Product> Products {
get
;
set
; }
}
2) A one-way optional association. I have a Site entity that has an optional dependency on a Template entity through the property Site.DefaultTemplate. Saving this association to the database works. Now I delete the Template entity and I wish this action also updates the property Site.DefaultTemplate to null. It's associated object is deleted after all. In the documenation I can only find information about Depends() for cascading deletes. I am basically looking for cascade on persist / update. Is there any such thing?