none
SQL 2005 User-defined Query with Entity Framework 3.5 RRS feed

  • Question

  • Hello,

    I have been looking all over and cannot find a solution to this problem. I have a UDF that was added to our Entity Model by way of Function Import. When I view the XML behind the Entity Model, I can see the function defined as such:

    <EntityContainer Name="EntityModel">
    <FunctionImport Name="udf_GetTimeZoneOffsetFromEST" ReturnType="Collection(Int32)" />
    </EntityContainer>
    

    I am trying to call this FunctionImport from the code as such:

    public int GetTimeZoneOffsetFromEST()
        {
          using (Context)
          {
            var sql = "EntityModel.udf_GetTimeZoneOffsetFromEST";
            var offset = Context.CreateQuery<byte>(sql);
    
            return 0;
          }
        }
    


    Though the Runtime exception being thrown says:

    		ErrorDescription	"The EntitySet 'udf_GetTimeZoneOffsetFromEST' is not defined in the EntityContainer 'EntityModel'."
    


    My problem is when I am trying to call upon this function from code. I know that it has to be written using eSQL, but I get an error every time. The post located on the forums here says all I need to do is call upon the namespace of the SSDL to access the function, but I am and it's not working. This post in the MSDN blog says just about the same thing.

    Can anyone help me clearly understand how I'm supposed to do this?

    Thanks in advance!

    Thursday, July 7, 2011 9:07 PM

Answers