Perhaps that's just pseudo-code, but I don't really recognize that stored procedure code, and I'm not sure that @a/@b will be an int, or that it won't get a "divide by zero" error. What database are you using? Generally your stored procedure declares any necessary input and output parameters. The return value is a status code, not your desired output. I have not used them, but I believe this is true of CLR stored procedures in SQL Server, as well.
Here's a simple T-SQL stored procedure for SQL Server:
Code:
CREATE PROCEDURE [dbo].[proc_GetEmployeeFullName] (
@ID int,
@FullName nvarchar(40) output
)
AS
BEGIN
SET NOCOUNT OFF
SELECT @FullName = LastName + N', ' + FirstName
FROM [Employee]
WHERE EmployeeID = @ID
RETURN @@Error
END
How to write a stored procedure for your database is not a subject we deal with in our forums. There are better places on the Web for that. As far as calling a stored procedure using EntitySpaces, in your custom class you would add a method to call it. For this example, we would put the following method in our Employee.cs custom class:
Code:
public string GetFullName(int ID)
{
esParameters parms = new esParameters();
parms.Add("ID", ID);
parms.Add("FullName", esParameterDirection.Output, DbType.String, 40);
this.ExecuteNonQuery(esQueryType.StoredProcedure, "proc_GetEmployeeFullName", parms);
return parms["FullName"].Value as string;
}
This would be an example of how you might use it in your app:
Code:
Employee emp = new Employee();
emp.LoadByPrimaryKey(1);
string fullName = emp.GetFullName(emp.EmployeeID.Value);
David Neal Parsons
www.entityspaces.net