Different Read/Update Views/Tables
Posted: Tue 30 Jul 2013 10:30
Hi there,
Is it possible to specify different table/view names for SELECT and DML operations for Entity Framework?
The reason:
1) I have a normal table USERS with data (TS column used for concurrency check, filled in trigger on insert and update - StoreGeneratedPattern - Computed).
2) I have a view TUSERS, that exposes USERS table and adds few calculated columns.
3) I have instead of trigger on TUSERS view, that intercepts changes to calculated columns and performs additional business logic.
4) EF fails to update TUSERS because of RETURNING statement.
Possible solutions:
A) Make DevArt EF to generate valid SQL for DML (e.g. WITHOUT RETURNING, but with Entity Keys). Estimated time?
B) Add empty columns to USERS table, define normal trigger just for those columns, implement business logic inside the trigger. In this case USERS and TUSERS have the same structure, so TUSERS can be used for SELECT and USERS for DML. So RETURNING will work properly. Now the question, how to tell DevArt EF to use different table names for SQL generation?
UPDATE1.
C) As a variant, possibility to intercept DbCommand before execution (aka EF6) and modify CommandText. How realistic?
D) Any other solutions? maybe there is an typical solution I miss?
Thank you in advance,
Lex
Is it possible to specify different table/view names for SELECT and DML operations for Entity Framework?
The reason:
1) I have a normal table USERS with data (TS column used for concurrency check, filled in trigger on insert and update - StoreGeneratedPattern - Computed).
2) I have a view TUSERS, that exposes USERS table and adds few calculated columns.
3) I have instead of trigger on TUSERS view, that intercepts changes to calculated columns and performs additional business logic.
4) EF fails to update TUSERS because of RETURNING statement.
Possible solutions:
A) Make DevArt EF to generate valid SQL for DML (e.g. WITHOUT RETURNING, but with Entity Keys). Estimated time?
B) Add empty columns to USERS table, define normal trigger just for those columns, implement business logic inside the trigger. In this case USERS and TUSERS have the same structure, so TUSERS can be used for SELECT and USERS for DML. So RETURNING will work properly. Now the question, how to tell DevArt EF to use different table names for SQL generation?
UPDATE1.
C) As a variant, possibility to intercept DbCommand before execution (aka EF6) and modify CommandText. How realistic?
D) Any other solutions? maybe there is an typical solution I miss?
Thank you in advance,
Lex