Note that there are some explanatory texts on larger screens.

plurals
  1. POADO.NET Entity : limiting data selection based on View
    text
    copied!<p>Consider following example:</p> <p>SQL Table Customer:</p> <pre><code>ID: Primary Key Name: Name </code></pre> <p>SQL View ViewCustomerSelection:</p> <pre><code>ID: Link to Customer ID SomeOption: Not important </code></pre> <p>I'd like to create ADO.NET an entity that only selects customers that have corresponding values in ViewCustomerSelection</p> <p>Following does NOT work:</p> <ul> <li>Create entity that maps to Customer and to ViewCustomerSelection without using any conditions and any fields from ViewCustomerSelection : ViewCustomerSelection is not included in SQL and all customers are returned.</li> <li>Include a field from ViewCustomerSelection : Correct selection is returned but now Customer object is not updateable </li> <li>Specify "not null" condition on SomeOption field : error - "Property ViewCustomerSelection.SomeOption with 'IsNull=false' condition must be mapped.</li> <li>Specify "not null" condition on ViewCustomerSelection.ID field : error - "Entity type contains a condition on its primary key. Please remove the condition from the mapping.</li> </ul> <p>Clarification </p> <p>Database definition:</p> <pre><code>create table Customer { ID [int] IDENTITY(1,1) NOT NULL, Name [varchar](50) NOT NULL } CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED ( [ID] ASC ) create table ViewCustomerSelection as select customer.id, ToUpper(customer.name) as SomeOption where customer.name like 'A%' </code></pre> <p>I'd like to have entity Customer with ID and name, that only has records for records present in ViewCustomerSelection (note - in actuality the view is more complicated and can not be expressed using simple conditions)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload