tags:

views:

174

answers:

1

How do i get the identity. The following code enters a value into orderItem. I wish to return orderItemId.

public static StoredProcedure StoreAddToCartSAS(string userName, SAS.Business.Domain.Product product)
    {
        SubSonic.StoredProcedure sp = new SubSonic.StoredProcedure("Store_AddItemToCart", DataService.GetInstance("dashCommerce"), "dbo");

        sp.Command.AddParameter("@productName", product.ProductName, DbType.String);

        return sp;
    }
+2  A: 

That code only creates an SP for you - it doesn't execute it. Assuming the SP returns the new ID with a SELECT:

SELECT @@IDENTITY as newID;

Then you can do this:

var newID=sp.ExecuteScalar();

Rob Conery