我怎样才能在Entity FrameWork中看到执行命令?

时间:2010-08-23 13:12:12

标签: c# .net visual-studio linq entity-framework

我尝试使用erpCtx.Executecommand但我没有executecommand方法。我认为我必须在参考中添加dll来显示executeCommand吗?

alt text

我需要: int rowsAffected = engCtx.ExecuteCommand(“插入xtable值({0},{1},{2},{3})”,engArray [0],engArray {{3} },engArray [2],engArray [3]);

3 个答案:

答案 0 :(得分:2)

在实体框架中,它被称为ExecuteStoreCommand

答案 1 :(得分:0)

这样的东西?

 using (var db = new DAL.CrawlerDalEntities())
        {
            db.Connection.Open();
            using (var cmd = db.Connection.CreateCommand())
            {
                cmd.CommandTimeout = storedProcedureDefaultTimeout;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "CrawlerDalEntities.PerformBackup";

                cmd.Parameters.Add(new EntityParameter
                {
                    ParameterName = "fileName",
                    Value = fileName,
                    DbType = DbType.String
                });

                cmd.Parameters.Add(new EntityParameter
                {
                    ParameterName = "backupName",
                    Value = backupName,
                    DbType = DbType.String
                });

                cmd.ExecuteNonQuery();
            }
            db.Connection.Close();
        }

答案 2 :(得分:0)

DataContext.ExecuteCommand位于:

  

命名空间: System.Data.Linq
  汇编: System.Data.Linq(在System.Data.Linq.dll中)

Source