public void InsertAll <T>(T[] objects) { var desc = Registory.GetClassDesc <T>(); foreach (T obj in objects) { string insert = SQLMaker.GenerateInsertSQL(desc, obj); database.ExecuteNonQuery(insert); } }
public void UpdateAll <T>(T[] objects) { var desc = Registory.GetClassDesc <T>(); foreach (T obj in objects) { string update = SQLMaker.GenerateUpdateSQL(desc, obj); database.ExecuteNonQuery(update); } }
/// <summary> /// Delete all record then insert. /// </summary> /// <param name='objects'> /// Objects. /// </param> /// <typeparam name='T'> /// The 1st type parameter. /// </typeparam> public void ReplaceAll <T>(T[] objects) { var desc = Registory.GetClassDesc <T>(); string delete = SQLMaker.GenerateDeleteAllSQL <T>(desc); database.ExecuteNonQuery(delete); foreach (T obj in objects) { string insert = SQLMaker.GenerateInsertSQL(desc, obj); database.ExecuteNonQuery(insert); } }
public T ReadByKey <T>(object key) where T : class { var desc = Registory.GetClassDesc <T>(); var result = database.ExecuteQuery( SQLMaker.GenerateSelectSQL <T>(desc, key)); T[] r = ResultReader.Get <T>(result, desc); if (r.Length > 0) { return(r[0]); } else { return(null); } }
public void UpdateOrInsert <T>(T obj) { var desc = Registory.GetClassDesc <T>(); string queryData = SQLMaker.GenerateSelectSQL <T> (desc, obj); try{ DataTable queryResult = database.ExecuteQuery(queryData); if (queryResult.Rows.Count > 0) { // Debug.Log(":: Update Data"); string update = SQLMaker.GenerateUpdateSQL(desc, obj); database.ExecuteNonQuery(update); } else { // Debug.Log(":: Insert Data"); string insert = SQLMaker.GenerateInsertSQL(desc, obj); database.ExecuteNonQuery(insert); } }catch (SqliteException e) { Debug.Log("Fail! err: " + e.ErrorCode + " - " + e.Message); } }
public void DeleteByKey <T>(object key) { var desc = Registory.GetClassDesc <T>(); database.ExecuteNonQuery(SQLMaker.GenerateDeleteSQL <T>(desc, key)); }
public void DeleteAll <T>() { var desc = Registory.GetClassDesc <T>(); database.ExecuteNonQuery(SQLMaker.GenerateDeleteAllSQL <T>(desc)); }