Entity Framework function call import from code

So, I have a Spr_EventLogCreate stored procedure defined in my database. I created a function import in my data model called LogEvent with no return type, and I see this function in the model browser tree in

MyModel.edmx> MyModel> EntityContainer> Import Functions> LogEvent.

I thought that then I would need to call a function in my code as follows:

var context = new MyModelEntities();
context.LogEvent(...);

But there is no LogEvent () method.

I should be really stupid here, but how can I name my imported function?

Using VS 2008 and EF 3.5.

+3
source share
1 answer

, , Microsoft . , , . :


        public void EmpDelete (global::System.Nullable PEMPNO, global::System.Nullable PDEPTNO)
        {
            if (this.Connection.State != System.Data.ConnectionState.Open)
              this.Connection.Open();
            System.Data.EntityClient.EntityCommand command = new System.Data.EntityClient.EntityCommand();
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.CommandText = @"DataSourceModel1Entities.EmpDelete";
            command.Connection = (System.Data.EntityClient.EntityConnection)this.Connection;
            EntityParameter PEMPNOParameter = new EntityParameter("PEMPNO", System.Data.DbType.Decimal);
            if (PEMPNO.HasValue)
                PEMPNOParameter.Value = PEMPNO;
            command.Parameters.Add(PEMPNOParameter);
            EntityParameter PDEPTNOParameter = new EntityParameter("PDEPTNO", System.Data.DbType.Decimal);
            if (PDEPTNO.HasValue)
                PDEPTNOParameter.Value = PDEPTNO;
            command.Parameters.Add(PDEPTNOParameter);
            command.ExecuteNonQuery();
        }
+2

Source: https://habr.com/ru/post/1736047/


All Articles