Carrotware.CMS.DBUpdater.DatabaseUpdate.ApplyUpdateIfNotFound C# (CSharp) Метод

ApplyUpdateIfNotFound() публичный Метод

public ApplyUpdateIfNotFound ( string testQuery, string updateStatement, bool bIgnore ) : DatabaseUpdateResponse
testQuery string
updateStatement string
bIgnore bool
Результат DatabaseUpdateResponse
        public DatabaseUpdateResponse ApplyUpdateIfNotFound(string testQuery, string updateStatement, bool bIgnore)
        {
            DatabaseUpdateResponse res = new DatabaseUpdateResponse();
            DataTable table1 = GetTestData(testQuery);

            if (table1.Rows.Count < 1) {
                res.LastException = ExecScriptContents(updateStatement, bIgnore);
                res.Response = "Applied update";
                res.RanUpdate = true;
                return res;
            }

            res.Response = "Did not apply any updates";
            return res;
        }

Usage Example

		public ActionResult CalendarDatabase() {
			List<string> lst = new List<string>();

			DatabaseUpdate du = new DatabaseUpdate();
			DatabaseUpdateResponse dbRes = new DatabaseUpdateResponse();

			string sqlUpdate = String.Empty;
			string sqlTest = String.Empty;

			try {
				sqlUpdate = WebHelper.ReadEmbededScript("CarrotCake.CMS.Plugins.CalendarModule.tblCalendar.sql");

				sqlTest = "select * from [INFORMATION_SCHEMA].[COLUMNS] where table_name in('tblCalendar')";
				dbRes = du.ApplyUpdateIfNotFound(sqlTest, sqlUpdate, false);

				if (dbRes.LastException != null && !string.IsNullOrEmpty(dbRes.LastException.Message)) {
					lst.Add(dbRes.LastException.Message);
				} else {
					lst.Add(dbRes.Response);
				}
			} catch (Exception ex) {
				lst.Add(ex.ToString());
			}

			return View(lst);
		}
All Usage Examples Of Carrotware.CMS.DBUpdater.DatabaseUpdate::ApplyUpdateIfNotFound