I have inherited some code (that happens a lot!) which looks a bit like this: (namespace omitted)
public partial class SpatialDatabase : global::System.Data.Objects.ObjectContext
{
public string MY_PROCEDURE(Decimal arg1, Decimal arg2)
{
using (EntityConnection conn = new EntityConnection(this.Connection.ConnectionString))
{
conn.Open();
object a = new System.Data.Objects.ObjectContext(new EntityConnection());
EntityCommand cmd = conn.CreateCommand();
cmd.CommandText = "SpatialDatabaseContext.MY_PROCEDURE";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("ARG1", arg1);
cmd.Parameters.AddWithValue("ARG2", arg2);
EntityParameter resultParam = cmd.Parameters.Add("RESULT", DbType.String, 100);
resultParam.Direction = ParameterDirection.Output;
int c = cmd.ExecuteNonQuery();
return (string)resultParam.Value;
}
}
}
This gives me a sqiggly blue line under my class name with the error message.
I know that this code works. This is running elsewhere on site just fine. So why would this copy give me this error?
[Edit]
In reality, what happens is that the missing constructor is added when the EDMX file is built from the database objects. That's why it's a partial class! We learn something new every day!
[/Edit]