我有以下存储过程,但在导入Visual Studio 2015的实体框架时,没有列。我在程序声明之前和之后尝试过SET FMTONLY OFF,但仍然没有运气。
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET FMTONLY OFF
GO
ALTER PROCEDURE [dbo].[up_Search] (
@name VARCHAR(255) = NULL,
@position VARCHAR(10) = NULL,
@altposition VARCHAR(10) = NULL,
@notice VARCHAR(10) = NULL,
@lengthofservice VARCHAR(10) = NULL,
@source VARCHAR(10) = NULL,
@educationLevel VARCHAR(10) = NULL,
@email VARCHAR(10) = NULL,
@CVRead CHAR = NULL,
@SARef CHAR = NULL,
@Collections CHAR = NULL,
@Sales CHAR = NULL,
@TeamLead CHAR = NULL,
@Training CHAR = NULL,
@HR CHAR = NULL,
@Business CHAR = NULL,
@UK CHAR = NULL,
@fromDate varchar(20) = NULL,
@toDate varchar(20) = NULL,
@ExperienceID_1 varchar(50) = null,
@ExperienceID_2 varchar(50) = null,
@Language_1 varchar(20) = NULL
)
AS
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
DECLARE @sql varchar(max)
DECLARE @i int
DECLARE @firstname VARCHAR(255), @lastname VARCHAR(255)
PRINT @educationLevel
SET @name = LTRIM(@name)
SET @i = CHARINDEX(' ', @name)
if @i > 1
begin
set @firstname = LEFT(@name, @i-1)
set @lastname = RIGHT(@name, LEN(@name)-@i)
end
SET @sql = 'SELECT c.[CandidateID] as [Unique ID] ,[DateOfApplication] as [Date Of Application],
ISNULL ( RecruiterDisplayName , ''---'') as [Recruiter]
,p.[Description] as [Position] ,t.Description as [Title] ,[FirstName] as [First Name] ,[LastName] as [Last Name]
,[IDNumber] as [ID Number] ,[Mobile] as [Mobile] ,[Email] as [Email] ,s.[Description] as [From Advert],
c.[LengthOfServicePersonal] as [LengthOfService]
FROM Candidate c
LEFT JOIN Position p ON c.PositionID = p.PositionID
LEFT JOIN SourceAdvert s ON c.SourceAdvertID = s.SourceAdvertID
LEFT JOIN Titles t ON c.TitleID = t.TitleID
LEFT JOIN Lookup_Experience le ON le.CandidateID = c.CandidateID
LEFT JOIN Experience ex ON ex.[ExperienceID] = le.[ExperienceID]
LEFT JOIN Languages ln ON ln.[LanguageID] = c.[Language]
WHERE (c.Status =0) ' -- only show candidates with not set status
if @firstname is not null
set @sql = @sql + ' AND (FirstName LIKE ''%' + @firstname + '%'' AND LastName LIKE ''%' + @lastname + '%'' OR IDNumber LIKE ''%' + @name + '%'')'
else begin
set @sql = @sql + ' AND (FirstName LIKE ''%' + @name + '%'' OR LastName LIKE ''%' + @name + '%'' OR IDNumber LIKE ''%' + @name + '%'')'
end
if @notice is not null
set @sql = @sql + ' AND (NoticePeriod <= ' + @notice + ')'
if @position is not null AND @altposition is not null
set @sql = @sql + ' AND (c.PositionID = ' + @position + ' OR c.AlternatePositionID = ' + @altposition + ')'
else
if @position is not null and @altposition is null
set @sql = @sql + ' AND c.PositionID = ' + @position
else
if @position is null and @altposition is not null
set @sql = @sql + ' AND c.AlternatePositionID = ' + @altposition
if @lengthofservice is not null
set @sql = @sql + ' AND (LengthOfService_1 >= ' + @lengthofservice +
' OR LengthOfService_2 >= ' + @lengthofservice +
' OR LengthOfService_3 >= ' + @lengthofservice +
' OR LengthOfService_4 >= ' + @lengthofservice +
')'
if @source is not null
set @sql = @sql + ' AND (s.[SourceAdvertID] = ' + @source + ')'
if @educationLevel is not null
set @sql = @sql + ' AND (EducationLevel >= ' + @educationLevel + ')'
if @email is not null and @email <> ''
set @sql = @sql + ' AND (Email like ''%'+ @email + '%'')'
if @CVRead is not null
set @sql = @sql + ' AND (CVRead = ' + CAST(@CVRead AS CHAR(1)) + ')'
if @SARef is not null
set @sql = @sql + ' AND (SARef = ' + CAST(@SARef AS CHAR(1)) + ')'
if @Collections is not null
set @sql = @sql + ' AND (Collections = ' + CAST(@Collections AS CHAR(1)) + ')'
if @Sales is not null
set @sql = @sql + ' AND (Sales = ' + CAST(@Sales AS CHAR(1)) + ')'
if @TeamLead is not null
set @sql = @sql + ' AND (TeamLead = ' + CAST(@TeamLead AS CHAR(1)) + ')'
if @Training is not null
set @sql = @sql + ' AND (Training = ' + CAST(@Training AS CHAR(1)) + ')'
if @HR is not null
set @sql = @sql + ' AND (HR = ' + CAST(@HR AS CHAR(1)) + ')'
if @Business is not null
set @sql = @sql + ' AND (Business = ' + CAST(@Business AS CHAR(1)) + ')'
if @UK is not null
set @sql = @sql + ' AND UK = ' + CAST(@UK AS CHAR(1))
if @fromDate is not null
set @sql = @sql + ' AND [DateOfApplication] >= ''' + @fromDate + ''''
if @toDate is not null
set @sql = @sql + ' AND [DateOfApplication] <= ''' + @toDate + ''''
if @ExperienceID_1 is not null AND @ExperienceID_2 is null
set @sql = @sql + ' AND ex.description = ''' + @ExperienceID_1 + ''''
if @ExperienceID_2 is not null
set @sql = @sql + ' AND (ex.description = ''' + @ExperienceID_1 + ''' OR ex.description = ''' + @ExperienceID_2 + ''')'
if @Language_1 is not null
set @sql = @sql + ' AND ln.Description = ''' + @Language_1 + ''''
set @sql = @sql + ' ORDER BY [LastTouched] DESC, [Date Of Application] DESC';
PRINT @sql
EXECUTE (@sql)
答案 0 :(得分:0)
我已经解决了我的问题。我所做的是创建一个具有相同名称和参数的存储过程,但只有一个简单的选择查询将返回列 - 我已经从PRINT @sql复制了查询结果。然后我用该过程更新实体框架,该过程有列。保存Visual Studio中的所有更改后,我使用旧的存储过程更改过程,一切正常100%