WSSF Factory and Stored Procedure OUT Parameters

Topics: General Discussion Forum, July and December Releases Forum, Service Factory Modeling Edition Forum
Oct 25, 2007 at 9:16 AM
Edited Oct 25, 2007 at 9:19 AM
Hi, all.
I have a question about Web Client Software Factory.

In the process to create a WSSF solution,
i run the Guidance Package Wizard, Data Access – Create Repository.

The wizard creates the Repository and Factory Classes, but , in the Costruct Command methods, doesn't write code
to add OUT stored procedures parameters.

Es:
- Stored procedure : InsertOrder
(insert new order in an Order table returning newOrderId)
PROCEDURE dbo.InsertOrder
@OrderDesc varchar(50),
@OrderId int OUT

- OrderInsertFactory class , generated by wizard:
public DbCommand ConstructInsertCommand(Database db, Order order)
{
DbCommand command = db.GetStoredProcCommand("dbo.InsertOrder");

if (order.Description != null)
{
db.AddInParameter(command, "orderDesc", DbType.String, country.CountryDesc);
}

return command;
}


it doesn't work because an AddOutParameter call is needed to invoke stored procedure , so I have to modify the code in this way:

public DbCommand ConstructInsertCommand(Database db, Order order)
{
DbCommand command = db.GetStoredProcCommand("dbo.InsertOrder");

if (order.Description != null)
{
db.AddInParameter(command, "orderDesc", DbType.String, country.CountryDesc);
}

//Add out parameter - No wizard generated
db.AddOutParameter(command, "@CountryId", DbType.Int32, 4);


return command;
}



Does anyone have suggestion to fix this behaviour to obtain the correct code without make changes?

Thanks in advance,

Vincent71
Oct 31, 2007 at 8:21 PM
Check are you selecting INSERT ONE.. Any thing else will not add the OUT Parameter
Nov 7, 2007 at 12:20 PM


webdeepak wrote:
Check are you selecting INSERT ONE.. Any thing else will not add the OUT Parameter

thanks, i'll try it.