I'm trying to create a WCF Data Layer using a DataModel. Concentrating on the model for the moment, I have imported a number of Stored Procs for use by the Data Layer. Taking one of the Stored Procs that Expects 3 parameters to be passed in, returns 6 values Decalred as Type Output in the SP Header. i.e
Then in my Service class that implements the interface, I have:
Code:
public ClientGetOccupationDetails GetOccupationDetails(Int32 UserID, Int32 ClientID, Int16 ClientVersion)
{
AIS_DEVEntities Dev = new AIS_DEVEntities();
}
How do return my values.
I have attached a screen shot of my Model Browser so that it might be clearer.
Ok, Because the SP has output parameters, I have declared my OperationContract as:
Code:
[OperationContract]
void GetOccupationDetails(Int32 UserID, Int32 ClientId, Int16 ClientVersion, out Int32? OccupationID, out String Code, out String Name, out String Description, out String ABIClass, out Int32? RiskClassID);
and in my Service Class I have:
Code:
public void GetOccupationDetails(Int32 UserID, Int32 ClientID, Int16 ClientVersion, out Int32? OccupationID, out String Code, out String Name, out String Description, out String ABIClass, out Int32? RiskClassID)
{
AIS_DEVEntities Dev = new AIS_DEVEntities();
ObjectParameter oCCOccupationID = null;
ObjectParameter oCode = null;
ObjectParameter oName = null;
ObjectParameter oDescription = null;
ObjectParameter oABIClass = null;
ObjectParameter oRiskClassID = null;
Dev.spCCClientGetOccupationDetails(UserID, ClientID, ClientVersion, oCCOccupationID, oCode, oName, oDescription, oABIClass, oRiskClassID);
OccupationID = Convert.ToInt32(oCCOccupationID);
Code = Convert.ToString(oCode);
Name = Convert.ToString(oName);
Description = Convert.ToString(oDescription);
ABIClass = Convert.ToString(oABIClass);
RiskClassID = Convert.ToInt32(oRiskClassID);
Dev.Dispose();
}
When I try and run this in the WCF Service Test Client (f5) and then enter valid values for the 3 input parameters (UserID, ClientID,ClientVersion) it errors with: the parameter at index 3 in the parameters array is null.
It would be because that is my first output param (cCoccupationID). This is on the Call to Dev.spCCClientGetOccupationDetails.