[LINQ] how to call Stored Procedure From EntityFramework (2)

Abstract: [LINQ] how to call Stored Procedure From EntityFramework (2)


The saying is another way to read, but above all, the Stored Procedure to join Entity Model
how to join, please refer to the first article: http://www.dotblogs.com.tw/constancy/archive/2013/10/ 31 / 126285.aspx

After the addition was complete, the data made available in the following ways

  EntityConnection entityConnection = (EntityConnection) this.context.Connection;
            DbConnection storeConnection = entityConnection.StoreConnection;
            //建构参数
            SqlParameter parameter1= new SqlParameter("@parameter1", SqlDbType.Text);
            //为参数赋予值
            parameter1.Value = parameterValue;

            storeConnection.Open();
                using (DbCommand command = storeConnection.CreateCommand())
                {
                    
                    command.CommandText = "reg.getTapqSubinfo";
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add(parameter1);                  
                    //取得一列数据
                    var result = command.ExecuteReader(CommandBehavior.SingleRow);
                    if (result.Read())
                        //取得某一个字段的值
                        return result.GetString(3);
                }

Original: Large column  [LINQ] how to call Stored Procedure From EntityFramework (2)


Guess you like

Origin www.cnblogs.com/chinatrump/p/11458445.html