예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #6
0
        public void DeleteByKey <T>(object key)
        {
            var desc = Registory.GetClassDesc <T>();

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

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