/// <summary> /// Update the specified item, or it doesn't exist, insert it. /// </summary> /// <param name="block_id"></param> /// <param name="min_level"></param> /// <param name="stack"></param> /// <param name="max_stack"></param> /// <param name="code"></param> /// <param name="name"></param> protected void updateItem(int block_id, int min_level, int stack, int max_stack, string code, string name) { Data.Item item = mDb.Items.SingleOrDefault(i => i.Block_Decimal_ID == block_id); if (item == null) { mDb.Items.InsertOnSubmit(new Data.Item() { Code = code, Name = name, Block_Decimal_ID = block_id, Min_Level = min_level, Stack_Size = stack, Max = max_stack }); } else { item.Block_Decimal_ID = block_id; item.Code = code; item.Max = max_stack; item.Min_Level = min_level; item.Name = name; item.Stack_Size = stack; } mDb.SubmitChanges(); }
public void CheckDatabaseState() { mDb = Manager.GetContext; if (!System.IO.File.Exists(datafile)) { UpdateDb creator = new CreateDb(); creator.DoUpdate(); UpdateDb inserter = new InsertData(); inserter.DoUpdate(); mDb.Configs.First(c => c.Key == "db_version").Value = CURRENT_VERSION.ToString(); } UpdateDatabase(); mDb.SubmitChanges(); }