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); }
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(); }