Created
          August 28, 2015 17:13 
        
      - 
      
 - 
        
Save dmitry-a-morozov/4f41882c8e96876c6252 to your computer and use it in GitHub Desktop.  
    Specifying a Parameter Default Value
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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