views:

29

answers:

1

I have an object that inherits the EF ObjectContext object and I want to call a Function Import I created. Anyone know how to do that? Do I have to use ExecuteFunction()?

Thanks!

A: 

I got it to work, but I put the code in a repository object. You could also put it in your custom ObjectContext object and it should work there as well. Here's the code...

public int LogOn(global::System.String UserName, global::System.String Password)
{
    ObjectParameter UserNameParameter;
    if (UserName != null)
    {
        UserNameParameter = new ObjectParameter("USERNAME", UserName);
    }
    else
    {
        UserNameParameter = new ObjectParameter("USERNAME", typeof(global::System.String));
    }

    ObjectParameter UserpasswordParameter;
    if (Password != null)
    {
        UserpasswordParameter = new ObjectParameter("USERPWD", Password);
    }
    else
    {
        UserpasswordParameter = new ObjectParameter("USERPWD", typeof(global::System.String));
    }

    return base.ExecuteFunction("LogOn", UserNameParameter, UserpasswordParameter);
}

"LogOn" is the name of the Function Import that I created to map to the logon stored Procedure.

Dan H