none
UDF does not show up in DataContext method list??? RRS feed

  • Question

  • I want to try using UDFs in my application, but not having much success.  I'm using sqlmetal to generate DataContext classes, and here is the code for the simple UDF I was playing around with:

    CREATE FUNCTION [dbo].[NameSearch]
    (
    	-- input parameter
    	@ApplicantName VARCHAR(50)
    )
    RETURNS INT
    AS
    BEGIN
    	-- declare the return variable
    	DECLARE @RecordCount int
    
    	-- t-sql used to populate the return variable
    	SELECT @RecordCount = COUNT(applicant_id)
    	FROM Applicant
    	WHERE full_name = @ApplicantName
    
    	-- return the result of the function
    	RETURN @RecordCount
    END
    
    I assume that a UDF would be called as a method like stored procedures, however, stored procedures are accessible from the DataContext object while this UDF is not??? 
    Wednesday, February 16, 2011 8:18 PM

Answers

  • Figured out why I couldn't "see" my UDF via intellisense or find it within the .cs file generated by sqlmetal:  I hadn't included the /functions parameter in the command line string used to generate my dataclasses.  Once I added this and re-generated the file the UDF was available.

    • Marked as answer by jabberpunch Wednesday, February 23, 2011 3:12 PM
    Wednesday, February 23, 2011 3:11 PM

All replies