Hello,
In CSLA "Editable Root" business object properties use class variables that declared inside class and initialized with default values like integers will default to 0 and strings will default to ""
Protected mName As String = ""
Protected mDepartmentID As Integer = 0
say for a database table Customer Table tehre is "DepartmentID" as foreign key at at Departments table DepartmentID is an int identity field with seed as 1 and increment as 1 als.
if DepartmentID is optional in business logic and in say ASP.NET GUI and we did not assign teh DepartmentID Customer object property a value
DepartmentID database column it will be saved as 0 in database but 0 can not be a foreign key value if we will enforce foreign key constraint as 0 can not be DepartmentID value at Departmens lookup table (it can be only NULL or a DepartmentID values that exist at Departments table).
any ideas about how to enforce foreign key relationship
on database tables that are wrapped by CSLA editable root business objects
Thanks
Tamer Halwagy
In your dataportal_insert/update you will need conditional code
that will send DBNull.Value to the backend instead of zero if you have a loose
relationship.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: tmr_halwagy
[mailto:cslanet@lhotka.net]
Sent: Tuesday, January 13, 2009 8:09 AM
To: Sergey Barskiy
Subject: [CSLA .NET] foreign key enforce with CSLA
Hello,
In CSLA "Editable Root" business object properties use class
variables that declared inside class and initialized with default values like
integers will default to 0 and strings will default to ""
Protected mName As String = ""
Protected mDepartmentID As Integer = 0
say for a database table Customer Table tehre is
"DepartmentID" as foreign key at at Departments table DepartmentID is
an int identity field with seed as 1 and increment as 1 als.
if DepartmentID is optional in business logic and in say ASP.NET GUI and we
did not assign teh DepartmentID Customer object property a value
DepartmentID database column it will be saved as 0 in database but 0 can not
be a foreign key value if we will enforce foreign key constraint as 0 can not
be DepartmentID value at Departmens lookup table (it can be only NULL or a
DepartmentID values that exist at Departments table).
any ideas about how to enforce foreign key
relationship
on database tables that are wrapped by CSLA
editable root business objects
Thanks
Tamer Halwagy
Hello,
What do you mean of loose relationship
1/0 to many
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: tmr_halwagy
[mailto:cslanet@lhotka.net]
Sent: Tuesday, January 13, 2009 9:47 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] foreign key enforce with CSLA
Hello,
What do you mean of loose relationship
Copyright (c) Marimer LLC