none
import a function that returns a scalar value

    Question

  • Hello,

    I have found that I can make a function import that returns a scalar value here:
    http://msdn.microsoft.com/en-us/library/bb896231.aspx

    1) But when I tried to add a stored function ( IsComposable="true") with "import function" menu option, I got:
    Error 2054: A FunctionImport is mapped to a storage function 'autotestModel.Store.GetNewValFunc' that can be composed. Only stored procedure functions may be mapped.

    2) When I add a stored procedure ( IsComposable="false"), the generation successfully ends,
    but there is no method realisation for this SP in the corresponding .cs file.

    Is there any sample for this particular case?

    Thanks.

    Regards,
    Alexey.
    Tuesday, June 24, 2008 3:00 PM

Answers

  • 1. As Julie says, this scenario is not yet supported.

     

    2. The EF does not generate code for sprocs that return scalar values - the feature was cut due to time constraints. The EFExtensions project on codegallery may be of some help there, I think.

    Tuesday, June 24, 2008 10:08 PM
    Moderator

All replies

  • Hi Alexey

     

    All stored procs must be listed as IsComposable=false. That's just a general rule to distinguish Stored Procedrues from TableValue functions. Stored Procs can't be part of queries that are sent to the database whereas tvf's can be.

     

    On your second question, did you do an import function to add the function to hte CSDL? If so, the function should be n the code gen'd file as a method of the EntityContainer.

    Tuesday, June 24, 2008 9:30 PM
  • 1. As Julie says, this scenario is not yet supported.

     

    2. The EF does not generate code for sprocs that return scalar values - the feature was cut due to time constraints. The EFExtensions project on codegallery may be of some help there, I think.

    Tuesday, June 24, 2008 10:08 PM
    Moderator
  •  

    Y'know, I remembered that you had told me something about the code gen with sprocs and couldn't remember WHAT it was or where I had  seen it - in an email, in the forums....

     

    I think I even have it noted in my book somewhere. I better go find out where! :-)

    Tuesday, June 24, 2008 10:20 PM
  • Hello,

    Thanks for the reply.

    Regards,
    Alexey.
    Wednesday, June 25, 2008 7:50 AM
  • Is this issue fixed in EF4.0?
    Arul
    Tuesday, May 18, 2010 4:16 PM