/// <summary> /// Used in the deletion and updating process to get the currently stored item to compare against. /// </summary> private TEntity GetSingle <TEntity> (int ID, CSDB_BASE context) where TEntity : class { if (Connection == null) { throw new Exception("No connection to database"); } if (typeof(IID).IsAssignableFrom(typeof(TEntity))) { try { return(context.GetTable <TEntity> ( ).Where(r => ((IID)r).ID == ID).ToArray().FirstOrDefault( )); } catch (Exception ex) { ChampionshipSolutions.Diag.Diagnostics.LogLine("Error selecting single entity from database of type " + typeof(TEntity).ToString( )); ChampionshipSolutions.Diag.Diagnostics.LogLine(ex.Message); return(null); throw; } } else { return(null); } }
internal static void InsertSchoolTeam(SchoolTeams ST, SQLiteConnection Connection) { using (CSDB_BASE context = new CSDB(Connection)) { string cmd = string.Format(@"INSERT INTO SchoolTeams (ID, School_ID, Team_ID) VALUES ({0}, {1}, {2})", CSDB_BASE.getNextIdentifier(typeof(SchoolTeams), context), ST.School.ID, ST.Team.ID); object[] obj = context.ExecuteQuery(cmd).FirstOrDefault(); } }