Using this example, I was able to create a working CRUD interface using a SQL view; however, when I added calculated columns to the view, I received the following error.
Sys.WebForms.PageRequestManagerServerErrorException: Update or insert of view or function 'dbo.vwEnum' failed because it contains a derived or constant field.
Here's the table class definition. CreateUser and UpdateUser are the calculated columns, and it works if they are removed. Does anyone know how to prevent the calculated columns from being updated?
| <Table Name="dbo.vwEnum" Member="vwEnums"> |
| <Type Name="vwEnum"> |
| <Column Name="EnumId" Type="System.Int32" DbType="Int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> |
| <Column Name="Created" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" /> |
| <Column Name="CreateUserId" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> |
| <Column Name="Updated" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" /> |
| <Column Name="UpdateUserId" Type="System.Int32" DbType="Int NOT NULL" CanBeNull="false" /> |
| <Column Name="Name" Type="System.String" DbType="VarChar(50) NOT NULL" CanBeNull="false" /> |
| <Column Name="Code" Type="System.String" DbType="VarChar(20) NOT NULL" CanBeNull="false" /> |
| <Column Name="Description" Type="System.String" DbType="VarChar(1000) NOT NULL" CanBeNull="false" /> |
| <Column Name="Attributes" Type="System.Xml.Linq.XElement" DbType="Xml" CanBeNull="true" UpdateCheck="Never" /> |
| <Column Name="CreateUser" Type="System.String" DbType="VarChar(153)" IsReadOnly="true" CanBeNull="true" /> |
| <Column Name="UpdateUser" Type="System.String" DbType="VarChar(153)" IsReadOnly="true" CanBeNull="true" /> |
| <Association Name="vwEnum_vwEnumValue" Member="vwEnumValues" ThisKey="EnumId" OtherKey="EnumId" Type="vwEnumValue" /> |
| </Type> |
| </Table> |