In VS 2008, if you add a function template to return a scalar, it will not add code to simplify its use. You need to directly access the function template - I use a partial class to create the necessary methods for usability. They recorded this in VS2010.
public DateTime GetDateTime() { var returnValue = new DateTime(); using (var connection = new EntityConnection(Connection.ConnectionString)) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "myStoredProc"; command.CommandType = CommandType.StoredProcedure; try { returnValue = Convert.ToDateTime(command.ExecuteScalar()); } finally { connection.Close(); } } } return returnValue; }
Additional Information: Importing Functions in an Entity Model with a Non Entity Return Type
bryanjonker
source share