예제 #1
0
        public bool TryGetValue(string key, out Region value)
        {
            RegionDictionaryElement element = context.RegionDictionaryElements.Where((el) => el.Name == key).FirstOrDefault();

            value = element?.Region;
            if (element == null)
            {
                return(false);
            }
            return(true);
        }
예제 #2
0
        public void Add(string key, Region value)
        {
            RegionDictionaryElement newElement = new RegionDictionaryElement();

            newElement.Name = key;
            if (value == null)
            {
                newElement.Region = null;
            }
            else
            {
                newElement.RegionID = value.ID;
            }
            context.RegionDictionaryElements.Add(newElement);
            context.SaveChanges();
        }