public Phrase Create(string phraseText) { var phraseWords = phraseText.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); if (!phraseWords.Any()) return null; var phraseNumber = SequenceQuery.Instance.GetPhraseNumber(); var wordSequence = 0; foreach (var phraseWord in phraseWords) { var id = SequenceQuery.Instance.GetPhraseWordId(); wordSequence++; var wordId = new WordQuery().GetOrCreateWord(phraseWord, false, false).Id; OracleDataLayer.Instance.DmlAction(_createNewPhraseWord, new KeyValuePair<string, object>(IdText, id), new KeyValuePair<string, object>(PhraseNumberText, phraseNumber), new KeyValuePair<string, object>(WordSequenceText, wordSequence), new KeyValuePair<string, object>(WordIdText, wordId)); } OracleDataLayer.Instance.Commit(); return new PhraseQuery {PhraseNumber = phraseNumber}.Get().SingleOrDefault(); }
private Group ReadGroupWord(OracleDataReader reader, out Word word) { word = null; if (!reader.Read()) return null; word = new WordQuery().GetWordById((int) reader[WordIdText]); return new Group { Name = (string) reader[GroupNameText] }; }
internal void Create(string wordText, int songId, int line, int column, bool commit) { if (string.IsNullOrEmpty(wordText)) return; var word = new WordQuery().GetOrCreateWord(wordText, true, commit); var id = SequenceQuery.Instance.GetSongWordId(); OracleDataLayer.Instance.DmlAction(_createSongWordStatement, new KeyValuePair<string, object>(IdText, id), new KeyValuePair<string, object>(SongIdText, songId), new KeyValuePair<string, object>(WordLineText, line), new KeyValuePair<string, object>(WordColumnText, column), new KeyValuePair<string, object>(WordIdText, word.Id)); if (commit) OracleDataLayer.Instance.Commit(); }
//public IEnumerable<Word> GetLike() //{ // var statement = _getStatement; // var parameters = new List<KeyValuePair<string, object>>(); // AddOrLikeComparison(ref statement, WordText, Word, parameters); // AddComparison(ref statement, RepetitionText, Repetition, parameters); // return OracleDataLayer.Instance.Select(ReadWords, statement, parameters.ToArray()); //} internal Word GetOrCreateWord(string text, bool increaseRepetition, bool commit) { if (string.IsNullOrEmpty(text)) return null; var word = new WordQuery {Word = text}.Get().SingleOrDefault(); if (word == null) { var repetition = increaseRepetition ? 1 : 0; word = WordCreator.Instance.Create(text, repetition, commit); } else if (increaseRepetition) { WordCreator.Instance.IncreaseRepetition(word.Id, commit); word.Repetitions++; } return word; }