Tuesday, 30 March 2021

Stored Procedures in Entity FrameWork Core ASP.Net Web API Core

 



   using (SqlConnection cn = getConnectionString())

            {

                string sql = "StoreProcName";

                using (SqlCommand sqlCmd = new SqlCommand(sql, cn))

                {

                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    sqlCmd.Parameters.AddWithValue("@Param", "paramValue");

                    //cn.Open();

                    using (SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlCmd))

                    {

                        sqlAdapter.Fill(ds);

                    }

                }

            }


            ds.Tables[0].Columns.Add("AreasOfInterest");

            main = ds.Tables[0].ToList<Main>();

            dates = ds.Tables[1].ToList<Dates>();

            casOptions = ds.Tables[2].ToList<ModelName>();

          


No comments:

Post a Comment