This commit is contained in:
2018-09-19 15:37:54 +00:00
parent 893971e784
commit 8ee3370f60

View File

@@ -67,15 +67,18 @@ namespace AyaNova.Biz
return;
}
//BUILD A LIST OF SEARCHDICTIONARY ID'S FOR THE MATCHING WORDS
List<long> MatchingKeywordIdList = new List<long>();
//BUILD A LIST OF MatchingDictionaryEntry items FOR THE MATCHING WORDS
List<MatchingDictionaryEntry> MatchingKeywordIdList = new List<MatchingDictionaryEntry>();
//ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS
var ExistingKeywordMatches = ct.SearchDictionary.Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word);
//Put the matching keyword ID's into the list
foreach (KeyValuePair<long, string> K in ExistingKeywordMatches)
{
MatchingKeywordIdList.Add(K.Key);
bool IsName = false;
if (NameKeyWordList.Contains(K.Value))
IsName = true;
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName });
}
//ITERATE THROUGH THE KEYWORDS THAT DO *NOT* HAVE MATCHES IN THE SEARCHDICTIONARY AND ADD THEM TO THE SEARCH DICTIONARY, COLLECTING THEIR ID'S
@@ -89,7 +92,7 @@ namespace AyaNova.Biz
//Save the context in order to get the id's of the new words added
ct.SaveChanges();
====HERE
//Now add the id's of the newly created words to the matching keyword id list for this object
//OLD BORING WAY:
// foreach (SearchDictionary SD in ct.SearchDictionary.Local)
@@ -107,7 +110,21 @@ namespace AyaNova.Biz
ct.SearchDictionary.Add(new SearchKey() { Word = KeyWord });
}
}//eoc
//Class to hold temporary list of matching id
public class MatchingDictionaryEntry
{
public bool InName { get; set; }
public long DictionaryId { get; set; }
public MatchingDictionaryEntry()
{
InName = false;
DictionaryId = -1;
}
}
#endregion