Пример #1
0
        public int? Create(Note note)
        {
            const string sqlQuery = "INSERT INTO Notes (user_id, create_time, publish, title, body)" +
                                    " VALUES(@UserId, @CreateTime, @Publish, @Title, @Body);" +
                                    " SELECT CAST(SCOPE_IDENTITY() as int)";
            int? noteId = _db.Query<int>(sqlQuery, note).FirstOrDefault();

            return noteId;
        }
Пример #2
0
 public void Update(Note note)
 {
     const string sqlQuery = "UPDATE Notes SET " +
                             "publish = @Publish, " +
                             "title = @Title, " +
                             "body = @Body " +
                             "WHERE Id = @Id";
     _db.Execute(sqlQuery, note);
 }