예제 #1
0
        public static FlippedSentenceDto Convert(FlippedSentence domainModel)
        {
            if (domainModel == null)
            {
                return null;
            }

            return new FlippedSentenceDto
            {
                Id = domainModel.Id,
                Value = domainModel.Value,
                Created = domainModel.Created
            };
        }
예제 #2
0
        // Insert and select in one operation, solution taken from: https://stackoverflow.com/a/47110425/633098
        /// <summary>
        /// Asynchronously inserts the specified flipped sentence to the database and returns the just saved record.
        /// </summary>
        /// <param name="flippedSentence">The flipped sentence to persist.</param>
        public async Task <FlippedSentence> Add(FlippedSentence flippedSentence)
        {
            return(Convert(await(await GetConnection()).QuerySingleAsync <FlippedSentenceEntity>(@"INSERT INTO FlippedSentences

                                                                                                  (Value)
                                                                                                  
                                                                                                   OUTPUT INSERTED.*
                                                                                                  
                                                                                                   VALUES(@sentence)",


                                                                                                 new { Sentence = flippedSentence.Value },


                                                                                                 commandTimeout: CommandTimeout)));
        }