我创建了一个Complex Types
即GetIsActive_Result在DemoModel.edmx
. 它有一个,Scalar Property
即Int32类型的InvitationID。我创建了一个执行存储过程的函数。这是我的功能。
public GetIsActive_Result GetIsActiveUser(string email)
{
GetIsActive_Result result = null;
System.Data.Objects.ObjectParameter InvitationID;
InvitationID = new System.Data.Objects.ObjectParameter("InvitationID", -1);
var results = this.DataContext.GetIsActiveUser(email, InvitationID);
if (results != null)
{
result = results.FirstOrDefault();
}
return result;
}
该函数执行存储过程,即GetIsActiveUser。
USE [Demo]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[GetIsActiveUser]
(
@Email NCHAR(100),
@InvitationID INT OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY
IF EXISTS(select * from Users,Invitations where UserName=@Email and IsActive='Active' and Invitations.Email != @Email)
BEGIN
SET @InvitationID=1
END
ELSE IF EXISTS(select * from Users,Invitations where UserName=@Email and IsActive='InActive' and Invitations.Email = @Email)
BEGIN
SET @InvitationID=0
END
SELECT @InvitationID AS InvitationID
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK
END
EXEC ThrowError
END CATCH
END
这是一个返回InvitationID的简单存储过程。我在线收到以下错误result = results.FirstOrDefault();
不能隐式转换类型“int?” 到“DemoAppWebService.GetIsActive_Result”
我该如何解决这个错误?我的代码有什么问题?