Пример #1
0
 void ISynonymsRepository.CreateSynonyms(SynonymGroup synonymGroup)
 {
     using (var dc = new SynonymsDataContext(_connectionFactory.CreateConnection()))
     {
         dc.EquivalentTermEntities.InsertAllOnSubmit(synonymGroup.Map());
         dc.SubmitChanges();
     }
 }
Пример #2
0
        IList <SynonymGroup> ISynonymsRepository.GetSynonyms()
        {
            using (var dc = new SynonymsDataContext(_connectionFactory.CreateConnection()).AsReadOnly())
            {
                var synonymGroupMap = new Dictionary <Guid, SynonymGroup>();

                foreach (var entity in GetEquivalentTermEntities(dc))
                {
                    SynonymGroup synonymGroup;
                    if (!synonymGroupMap.TryGetValue(entity.equivalentGroupId, out synonymGroup))
                    {
                        synonymGroup = new SynonymGroup {
                            Id = entity.equivalentGroupId, Terms = new List <string>()
                        };
                        synonymGroupMap.Add(entity.equivalentGroupId, synonymGroup);
                    }

                    synonymGroup.Terms.Add(entity.searchTerm);
                }

                return(synonymGroupMap.Values.ToList());
            }
        }