Пример #1
0
        private IExecuteItemResponse ExecuteQuery(DeleteQuery deleteQuery)
        {
            var response = new ExecuteItemResponse()
            {
                Success      = false,
                RowsAffected = 0,
                ErrorMessage = string.Empty
            };

            if (!TryParsePrimaryValue(deleteQuery, out var primaryValue))
            {
                response.ErrorMessage = "Cannot find primary value from filter";
                return(response);
            }
            if (!TryGetEntity(deleteQuery.RootSchemaName, primaryValue, out var entity, out var errorMessage))
            {
                response.ErrorMessage = errorMessage;
                return(response);
            }
            try {
                response.Success      = entity.Delete();
                response.RowsAffected = 1;
            } catch (Exception e) {
                response.ErrorMessage = e.Message;
            }
            return(response);
        }
Пример #2
0
        private IExecuteItemResponse ExecuteQuery(InsertQuery insertQuery)
        {
            var response = new ExecuteItemResponse()
            {
                Success      = false,
                RowsAffected = 0,
                ErrorMessage = string.Empty
            };

            if (!TryGetEntity(insertQuery.RootSchemaName, out var entity, out var errorMessage))
            {
                response.ErrorMessage = errorMessage;
                return(response);
            }
            entity.SetDefColumnValues();
            SetColumnValues(entity, insertQuery.ColumnValues.Items);
            try {
                response.Success      = entity.Save(false);
                response.RowsAffected = 1;
            } catch (Exception e) {
                response.ErrorMessage = e.Message;
            }
            return(response);
        }