public void test() { shiftdbcontext db = new shiftdbcontext(); string commandText = "EXEC [dbo].[sp_shifts] @shiftId,@shiftname, @command"; var employees = db.Database.SqlQuery <Shift>(commandText, new SqlParameter("@shiftId", 1), new SqlParameter("@shiftname", "krishna"), new SqlParameter("@command", "SELECTALL")).ToList(); string shiftname2 = "testshift"; // string Command = "INSERT"; //SqlParameter latParam = new SqlParameter("@shiftname", shiftname); // SqlParameter lngParam = new SqlParameter("@command", Command); var param1 = new SqlParameter { ParameterName = "@shiftname", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, Value = "tsset" }; //Second input parameter var param2 = new SqlParameter { ParameterName = "@command", SqlDbType = SqlDbType.VarChar, Direction = ParameterDirection.Input, Value = "INSERT" }; var shiftname = new SqlParameter { DbType = DbType.String, ParameterName = "@shiftname", Value = "test" }; var command = new SqlParameter { DbType = DbType.String, ParameterName = "@command", Value = "SELECTALL" }; // object[] parameters = new object[] { latParam, lngParam }; //var list= db.Database.ExecuteSqlCommand("EXEC [dbo].[sp_shifts]",shiftname, command); db.Database.ExecuteSqlCommand( "EXEC [dbo].[sp_shifts] @shiftId,@shiftname, @command", new SqlParameter("@shiftId", 1), new SqlParameter("@shiftname", "krishna"), new SqlParameter("@command", "select") ); db.SaveChanges(); }
public void test() { shiftdbcontext db = new shiftdbcontext(); db.SaveChanges(); }