Can business object support more than one table?


Author
Message
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
As long as the view is an indexed view on SQL Server, allowing you to INSERT, UPDATE, and DELETE records from it, then what you have done is fine.  You might even be able to define a primary key index on the view within SQL Server, allowing you to avoid having to change that code each some you rebuild the partial class within SQL Server.
Wang Tong Yin
Wang Tong Yin
StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)
Group: Forum Members
Posts: 25, Visits: 46
I created a business object and mapped it to a view. When I tried to add record, an error occured. The error message as below

BusinessLayerException
 An error occurred while saving an the data to the server.
DataLayerSavingException
 Cannot create INSERT command because the updating DataTable does not contain columns for all PrimaryKeyFields.
DataLayerException
 Cannot create INSERT command because the updating DataTable does not contain columns for all PrimaryKeyFields.

Source     : MicroFour StrataFrame Business

Stack Trace:
   at MicroFour.StrataFrame.Data.DataLayer.BuildInsertInfo(DataTable UpdatingTable, Boolean Transactional, String TransactionKey)

.

.

.

I manually assigned one of the fields from the view to be the primary key. I changed the code in Business Object, Private Shared _PrimaryKeyFields As String() = New String() {""} to Private Shared _PrimaryKeyFields As String() = New String() {"customerId"}.

After that I can add and update the records using that business object. Is this the correct way to do it? Will it cause any problem?


StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The business objects will not prevent a user from being able to add new records, remove records or modify records if it is mapped to a view.  The best way to prevent the user modifying the business object would be to handle either the BeforeDelete and BeforeAddNew events and set e.Cancel = True.  Or you could handle the CheckSecurity event and deny the action.
Wang Tong Yin
Wang Tong Yin
StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)
Group: Forum Members
Posts: 25, Visits: 46
After I create a view within the database that selects its fields from the separate tables,  I will create a business object that will map to the columns of the view.  Some fields of the view are table's primary key, index key or candidate key. Will the business object automatically trap the error when user try to add, edit or delete record? If the business object can trap the error, where can I know the error occur? Is the Business Object return any message or raise any event?
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
I mean to create a view within the database that selects its fields from the separate tables.  You can then create a business object that will map to the columns of the view.  In answer to question #2, you cannot create a business object that can select fields from multiple business objects.  You would need to create a wrapper by hand that held the separate business objects.
Wang Tong Yin
Wang Tong Yin
StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)
Group: Forum Members
Posts: 25, Visits: 46
Do you mean:

     1. create a view that selects the appropriate fields from the separate business objects, or

     2. create a view that selects the appropriate fields from the separate tables?

Is it possible to  create a view that selects the appropriate fields from the separate business objects?

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If you create a view that selects the appropriate fields from the separate business objects, you can map a business object to that view.
Wang Tong Yin
Wang Tong Yin
StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)StrataFrame Novice (61 reputation)
Group: Forum Members
Posts: 25, Visits: 46
I tried to use Business Object Mapper to map the table to a business object. I found that I only can select one table. Is it possible that business object can work with more than one tables? For example, a business object can select the fields from three tables.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search