I have a model-first EF model. I just imported the first stored procedure: cpas_POIDVendorProjectDate
I imported it as a function. It has three input parameters: @ProjectID(int)
, @VendorID(int)
, and @Workdate(datetime)
, and returns @POID(int)
.
Here's the SQL code:
CREATE PROCEDURE [dbo].[cpas_POIDVendorProjectDate]
@VendorID int,
@ProjectID int,
@WorkDate datetime,
@PO_ID int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
DECLARE @RowCount int;
SELECT @PO_ID = ID FROM tblPO WHERE
VendorID = @VendorID
AND ExpirationDate >= @WorkDate
AND (ProjectID IS NULL OR ProjectID = @ProjectID)
AND CapitalExpense = (
SELECT CapitalExpense FROM tblProjects WHERE ID=@ProjectID)
AND GroupCode in (1,3,5);
SET @RowCount = @@RowCount;
IF (@RowCount != 1)
SET @PO_ID = -1*@RowCount;
END
I called it in my c# program as follows:
context.cpas_POIDVendorProjectDate(
currVendorID, currProjectID, currWorkDate, currPOID);
Intellisense says my use of "context" is wrong...It's a "variable", and I'm using it as a "method".
In addition, currPOID
is rejected because it's looking for a system.data.objects.OjbectParameter
, not an int
. Intellisense is happy with the function name and other parameters (strangely...)
What am I doing wrong here?