Database Reference
In-Depth Information
Figure 6-13. The WebOrder table containing information about a web order
Suppose that we have a business requirement, which defines instances of WebOrder as orders placed after the
first day of 2012 or orders placed between 2010 and 2012 that are not deleted or orders placed before 2010 that have an
order amount greater than $200. This kind of filter cannot be created using the rather limited conditions available in
the Mapping Details window in the designer. One way to implement this complex filter is to use QueryView. To model
this entity and implement a filter that satisfies the business requirement using QueryView, do the following:
1.
Add a new ADO.NET Entity Data Model to your project, and import the WebOrder table.
Create the stored procedures in Listing 6-27. In the next two steps, we'll map these to the
insert, update, and delete actions for the WebOrder entity.
Listing 6-27. Procedures Defined in the Database for the Insert, Update, and Delete Actions on the
WebOrder Entity
create procedure [Chapter6].[InsertOrder]
(@CustomerName varchar(50),@OrderDate date,@IsDeleted bit,@Amount decimal)
as
begin
insert into chapter6.WebOrder (CustomerName, OrderDate, IsDeleted, Amount)
values (@CustomerName, @OrderDate, @IsDeleted, @Amount)
select SCOPE_IDENTITY() as OrderId
end
go
create procedure [Chapter6].[UpdateOrder]
(@CustomerName varchar(50),@OrderDate date,@IsDeleted bit,
@Amount decimal, @OrderId int)
as
begin
update chapter6.WebOrder set CustomerName = @CustomerName,
OrderDate = @OrderDate,IsDeleted = @IsDeleted,Amount = @Amount
where OrderId = @OrderId
end
go
create procedure [Chapter6].[DeleteOrder]
(@OrderId int)
as
begin
delete from Chapter6.WebOrder where OrderId = @OrderId
end
 
Search WWH ::




Custom Search