Skip to content

Instantly share code, notes, and snippets.

@dmitry-a-morozov
Created August 28, 2015 17:13
Show Gist options
  • Save dmitry-a-morozov/4f41882c8e96876c6252 to your computer and use it in GitHub Desktop.
Save dmitry-a-morozov/4f41882c8e96876c6252 to your computer and use it in GitHub Desktop.
Specifying a Parameter Default Value
CREATE PROCEDURE [dbo].[spGetAutomobiles]
@Id int = 0,
@Make nvarchar(100) = ''
AS
BEGIN
SELECT *
FROM Automobiles a with (nolock)
WHERE (@Id = 0 OR a.Id = @Id)
AND (@Make = '' OR a.Make = @Make)
END
//Invoke from F#
let getById id = async {
use sproc = new Db.dbo.spGetAutomobiles()
return! sproc.AsyncExecuteSingle(id)
}
let getByMake make = async {
use sproc = new Db.dbo.spGetAutomobiles()
return! sproc.AsyncExecute(Make = make)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment