Exemplo n.º 1
0
        public State Create(State state)
        {
            const string SQL = @"
                                INSERT INTO STATE (Code, Name)
                                VALUES (@Code, @Name);
                                SELECT SCOPE_IDENTITY()
                                ";

            var id = ExecuteScalar(SQL, CommandType.Text, new[]
            {
                GetDbParameter("@Code", state.Code),
                GetDbParameter("@Name", state.Name)
            });

            state.Id = Convert.ToInt32(id);

            return state;
        }
Exemplo n.º 2
0
        public State Update(State state)
        {
            const string SQL = @" UPDATE STATE
                                  SET Code = @Code,
                                    Name = @Name
                                  WHERE Id = @Id
                                ";

            var id = ExecuteNonQuery(SQL, CommandType.Text, new[]
            {
                GetDbParameter("@Code", state.Code),
                GetDbParameter("@Name", state.Name),
                GetDbParameter("@Id", state.Id)
            });

            return state;
        }