Primary Key for Views


Author
Message
Flavelle Ballem
Flavelle Ballem
StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)
Group: Forum Members
Posts: 56, Visits: 126
I told you that I might be missing somethingBigGrin Thanks for clarifying that for me.
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
SQL Server 2005 will not let you define foreign keys from a view to other objects.  You can define indexes on a properly configured view, but not relationships and not primary keys, just regular indexes.  The PK definition within the BOMapper allows the BOMapper to specify the primary key when building the partial class for the business object.  This allows the business object to properly create the dynamic SQL at runtime that will be used to "insert" or "update" the view.  Without a primary key definition, an update from the BO to the database would fail because the WHERE clause of the update would not be able to specify only a single row.
Flavelle Ballem
Flavelle Ballem
StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)
Group: Forum Members
Posts: 56, Visits: 126
Wouldn't referential integrity rules be required if the View was being used to insert or update values? I'm probably missing something.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
That is the nice thing about the framework.  You can define the relationships within the business objects themselves.  The relationships defined on the BOs do not have to actually exist on the server.
Chris Crabtree
Chris Crabtree
StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)
Group: Forum Members
Posts: 57, Visits: 107
Okay...but if I can't define the view's PK in DDT, how do I define the relationships the view will have with the other tables, etc.?
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
Ah, the functionality was moved to the Business Object Mapper.  After you choose the view to which the business object gets its mapping information, you can go to the "advanced" options under the business object's properties and check the override primary key box, then click the "..." button and choose the fields that should be the primary key on the business object.
Chris Crabtree
Chris Crabtree
StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)StrataFrame User (157 reputation)
Group: Forum Members
Posts: 57, Visits: 107
As previously mentioned on here, one of the improvements v1.5 brings is the ability to define a PK on a view. This allows us to define a BO made up of multiple related tables, particularly the base-type/derived-type idiom, all within the database using SQL Server 'instead of' triggers on the view.

In essense, SF should treat such a view just like it was a normal table. But to get referential integrity support, SF needs to be able to assign the view a PK.

So now that I've just installed v1.5, I am apparently missing where in the DDT I would do that. It must be so obvious that I'm just looking in the wrong place...Smile

Thanks!

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