public static void AddLookupValue(Lookup lookupValue) { Dictionary<int, string> whole = cachedLookups[lookupValue.LookupName]; if (whole.ContainsKey(lookupValue.ID)) return; whole.Add(lookupValue.ID, lookupValue.Value); }
public static void Update(Lookup lookup) { using (LibraryDataContext ctx = new LibraryDataContext()) { ctx.Lookups.Attach(lookup); ctx.Entry(lookup).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } }
public static void Add(Lookup lookup) { using (LibraryDataContext ctx = new LibraryDataContext()) { using (DbContextTransaction transaction = ctx.Database.BeginTransaction()) { int nextID = ctx.Lookups.Where(l => l.LookupName == lookup.LookupName).Max(l => l.ID) + 1; lookup.ID = nextID; ctx.Lookups.Add(lookup); ctx.SaveChanges(); } } }
public static void UpdateLookupValue(Lookup lookupValue) { Dictionary<int, string> whole = cachedLookups[lookupValue.LookupName]; if (whole.ContainsKey(lookupValue.ID)) whole[lookupValue.ID] = lookupValue.Value; else whole.Add(lookupValue.ID, lookupValue.Value); }