Can business object support more than one table?


Author
Message
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.
Replies
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
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.
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