1
数据选择
考虑下面的例子:ADO.NET实体:限制基于浏览
SQL表的客户:
ID: Primary Key
Name: Name
SQL视图ViewCustomerSelection:
ID: Link to Customer ID
SomeOption: Not important
我想创建ADO.NET是一种只选择在ViewCustomerSelection中具有相应值的客户的实体
以下不工作:
- 创建一个映射到客户和ViewCustomerSelection不使用任何条件和任何ViewCustomerSelection领域实体:ViewCustomerSelection不包括在SQL和返回所有客户。
- 包括从ViewCustomerSelection场:正确选择返回,但现在客户对象是不可更新
- 指定的SomeOption场“不空”状态:错误 - “属性ViewCustomerSelection.SomeOption与‘ISNULL =假’的条件必须映射
- 在ViewCustomerSelection.ID字段上指定“not null”条件:error - “实体类型在其主键上包含一个条件。请从映射中删除条件。
澄清
数据库定义:
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%'
我想有实体与客户ID和姓名,只对在ViewCustomerSelection(本记录笔记的记录 - 实际上视图更复杂,不能用简单的条件表示)
你的问题真的不清楚 - 你能澄清一下吗? – BenAlabaster 2008-12-20 03:42:06