From 24d35d24d2dbfcb22c4624fe86f0c43641a03963 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Wed, 8 Feb 2017 22:23:45 +0000 Subject: [PATCH] use nameof compiler method to prevent the SQLiteProcedures constants needing to be rewritten and being too hard-coded. --- .../SQLiteRepository/SQLiteProcedures.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs index e04765c..4cc7aa7 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs @@ -2,20 +2,21 @@ namespace SQLiteRepository { internal static class SQLiteProcedures { - public const string GET_ALL_USERS = "select * from UserIdentity"; - public const string GET_USER_BY_ID = "select * from UserIdentity where Id=?"; + public const string GET_TIMELOGS = "select * from "+nameof(TimeLogDB)+ " where (" + nameof(TimeLogDB.UserId_FK) + "=? AND " + nameof(TimeLogDB.CalendarWeek) + "=? and " + nameof(TimeLogDB.Year) + "=?)"; + public const string GET_ALL_USERS = "select * from " + nameof(UserIdentity); + public const string GET_USER_BY_ID = "select * from " + nameof(UserIdentity) + " where " + nameof(UserIdentity.Id) + "=?"; - public const string GET_CARDS_BY_USER_ID = "select * from CardUniqueId where UserId_FK=?"; - public const string GET_CARDS_BY_UNIQUE_ID = "select * from CardUniqueId where CardUId=?"; - public const string GET_UNASSIGNED_CARD_LIST = "select * from CardUniqueId where UserId_FK=?"; + public const string GET_CARDS_BY_USER_ID = "select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?"; + public const string GET_CARDS_BY_UNIQUE_ID = "select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.CardUId) + "=?"; + public const string GET_UNASSIGNED_CARD_LIST = "select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?"; public const string GET_USER_BY_FIRST_AND_LAST = - "select * from UserIdentity where FirstName = ? AND LastName = ?"; + "select * from " + nameof(UserIdentity) + " where " + nameof(UserIdentity.FirstName) + " = ? AND " + nameof(UserIdentity.LastName) + " = ?"; - public const string UPDATE_CARD_USER_ID = "update CardUniqueId set UserId_FK=? where Id=?"; + public const string UPDATE_CARD_USER_ID = "update " + nameof(CardUniqueId) + " set " + nameof(CardUniqueId.UserId_FK) + "=? where " + nameof(CardUniqueId.Id) + "=?"; - public const string SEARCH_USER_LIST = "SELECT * FROM[UserIdentity] where(FirstName Like ? OR LastName Like ?)"; + public const string SEARCH_USER_LIST = "SELECT * FROM " + nameof(UserIdentity) + " where(" + nameof(UserIdentity.FirstName) + " Like ? OR " + nameof(UserIdentity.LastName) + " Like ?)"; - public const string GET_LAST_TIMELOG_DIRECTION = "SELECT * FROM TimeLog where UserId_FK = ? order by SwipeEventDateTime LIMIT 1"; + public const string GET_LAST_TIMELOG_DIRECTION = "SELECT * FROM " + nameof(TimeLogDB) + " where " + nameof(TimeLogDB.UserId_FK) + " = ? order by " + nameof(TimeLogDB.SwipeEventDateTime) + " LIMIT 1"; } } \ No newline at end of file