是否可以从存储过程中的多个视图中进行选择?我试过了,但没有用。b我觉得好像是因为我的实现是错误的。如果有人想看看,这是我的代码。当我将此 sp 添加到 linq 设计器并生成一个结果类时,它只有从 savearticle_v 视图中选择的字段,而不是 tag_v。
ALTER PROCEDURE [dbo].[mobile_GetSavedArticlesAR]
-- Add the parameters for the stored procedure here
@UserID int ,
@keyword1 varchar(50)='',
@keyword2 varchar(50)='',
@keyword3 varchar(50)='',
@keyword4 varchar(50)='',
@keyword5 varchar(50)='',
@Page int=1,
@PageLen int=20
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @RowStart int
declare @RowEnd int
IF (@Page=1)
Begin
set @RowStart=(@Page-1)*(@PageLen)
set @RowEnd=(@RowStart+@PageLen);
END
ELSE
BEGIN
set @RowStart=((@Page-1)*(@PageLen))+1
set @RowEnd=((@RowStart+@PageLen))-1
END;
With myArticles as
(select ROW_NUMBER() over (ORDER BY userID DESC) as 'RowNumber',*
From savedarticle_v
where UserID=@UserID and
title like '%'+@keyword1+'%' and
title like '%'+@keyword2+'%' and
title like '%'+@keyword3+'%' and
title like '%'+@keyword4+'%' and
title like '%'+@keyword5+'%'
)
select
rownumber,journalID,journalname,articleID,title,publicationdate,likes,aviews,comments ,medabbr
from myArticles where RowNumber Between @RowStart and @RowEnd;
With myTags as
(select ROW_NUMBER() over (ORDER BY userID DESC) as 'RowNumber',*
From tags_v
where userID=@UserID
)
select tagtext from myTags where RowNumber Between @RowStart and @RowEnd
END
GO