This is a migrated thread and some comments may be shown as answers.

CUD Mapping for a view

2 Answers 30 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MSu
Top achievements
Rank 2
MSu asked on 08 Jul 2016, 06:57 AM

Hello,

I defined an update stored procedure mapping for a view in the mapping details editor.

The new defined stored procedure appears in the model schema explorer.

In a next step i open the 'update database from model ..' form. Then i choose the migrate option .. click next ...

now I check the generated script ...... but the new defined stored procedure doesn't appear in the sql script block....

so that means that I can't generate the procedure on my SQL Server.

What I'm doing wrong  .... any ideas?

Thanks for helping..

Marco

2 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Zhivkov
Telerik team
answered on 15 Jul 2016, 09:21 AM
Hello Marco,

In general our recommendation is to use mapped views only for read-only operations. Allowing Create, Update and Delete operations over a view is tricky as behavior largely depends on the view definition. 
The issue that is preventing you from getting your Update procedure in the DDL scripts is cause by two facts:
1. Telerik Data Access Runtime does not support CUD operations for Views
2. Visual Designer does not distinguish between tables and views so it allows you to apply an unsupported feature to your view.

Please excuse us for the confusion.
I would suggest two different approaches to work around this limitation
1. Use the view as read-only data source and persist any changes via dedicated persistent types bound to tables.
2. Create the required stored procedure manually and add it to your model from the database. Call it manually whenever you want to modify a record in the view. Do not forget to commit the transaction for the procedure call by calling context.SaveChanges().

If you need any further assistance, please let us know.

Regards,
Viktor Zhivkov
Telerik by Progress
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
0
MSu
Top achievements
Rank 2
answered on 15 Jul 2016, 10:31 AM

Thanks four Your answer.

I found another way to realize my needed behaviour.

I defined an insteadof trigger for the mention view. So I implemented the logic sql server side.

Regards,

Marco.

Tags
Data Access Free Edition
Asked by
MSu
Top achievements
Rank 2
Answers by
Viktor Zhivkov
Telerik team
MSu
Top achievements
Rank 2
Share this question
or