This commit is contained in:
@@ -69,12 +69,32 @@ namespace AyaNova.Biz
|
||||
return;
|
||||
}
|
||||
|
||||
//List<long> MatchingKeywordIdList = new List<long>();
|
||||
//BUILD A LIST OF SEARCHDICTIONARY ID'S FOR THE MATCHING WORDS
|
||||
List<long> MatchingKeywordIdList = new List<long>();
|
||||
|
||||
//ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS
|
||||
List<long> MatchingKeywordIdList = ct.SearchDictionary.Where(m => KeyWordList.Contains(m.Word)).Select(m => m.Id).ToList();
|
||||
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);
|
||||
}
|
||||
|
||||
//ITERATE THROUGH THE KEYWORDS THAT DO *NOT* HAVE MATCHES IN THE SEARCHDICTIONARY AND ADD THEM TO THE SEARCH DICTIONARY, COLLECTING THEIR ID'S
|
||||
foreach (string KeyWord in KeyWordList)
|
||||
{
|
||||
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
|
||||
{
|
||||
ct.SearchDictionary.Add(new SearchDictionary() { Word = KeyWord });
|
||||
}
|
||||
}
|
||||
//Save the context in order to get the id's of the new words added
|
||||
ct.SaveChanges();
|
||||
//Now add the id's of the newly created words to the matching keyword id list for this object
|
||||
foreach (SearchDictionary SD in ct.SearchDictionary.Local)
|
||||
{
|
||||
MatchingKeywordIdList.Add(SD.Id);
|
||||
}
|
||||
|
||||
//CREATE THE SEARCHKEY RECORDS FOR ALL THE KEYWORDS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user