Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        /// <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);
            }
        }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
        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);
            }
        }
Exemple #6
0
        public void DeleteByKey <T>(object key)
        {
            var desc = Registory.GetClassDesc <T>();

            database.ExecuteNonQuery(SQLMaker.GenerateDeleteSQL <T>(desc, key));
        }
Exemple #7
0
        public void DeleteAll <T>()
        {
            var desc = Registory.GetClassDesc <T>();

            database.ExecuteNonQuery(SQLMaker.GenerateDeleteAllSQL <T>(desc));
        }