예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>The async.</returns>
        public async Task <bool> IsTableExists(string tableName)
        {
            var result = await SQLClient.getInstance().GetOrCreateConnection()
                         .ExecuteScalarAsync <int>("SELECT count(*) FROM sqlite_master WHERE type='table' AND name='" + tableName + "'");

            return(result == 1);
        }
예제 #2
0
        /// <summary>
        /// Inserts the async.
        /// </summary>
        /// <returns>The async.</returns>
        /// <param name="item">Item.</param>
        public async Task <int> InsertAsync(T item)
        {
            SQLClient             client     = SQLClient.getInstance();
            SQLiteAsyncConnection connection = client.GetOrCreateConnection();

            try
            {
                int n = await connection.InsertAsync(item);

                if (n == 0)
                {
                    System.Diagnostics.Debug.WriteLine("A");
                    return(n);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("B");
                    return(n);
                }
            }
            catch (Exception e) {
                System.Diagnostics.Debug.WriteLine("Error");
            }
            return(1);
        }
예제 #3
0
        public static SQLClient getInstance()
        {
            if (Instance == null)
            {
                Instance = new SQLClient();
            }

            return(Instance);
        }
예제 #4
0
        public static async Task <bool> CreateDatabaseForSDK()
        {
            SQLClient             client     = SQLClient.getInstance();
            SQLiteAsyncConnection connection = client.GetOrCreateConnection();

            try
            {
                await connection.CreateTableAsync <Account>();

                await connection.CreateTableAsync <User>();

                await connection.CreateTableAsync <Events>();

                await connection.CreateTableAsync <Idea>();

                return(true);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Salesforce SDK Database creation Failed" + e.Message);
                return(false);
            }
        }
예제 #5
0
 /// <summary>
 /// Firsts the or default async.
 /// </summary>
 /// <returns>The or default async.</returns>
 public async Task <T> FirstOrDefaultAsync()
 {
     return(await SQLClient.getInstance().GetOrCreateConnection().Table <T>().FirstOrDefaultAsync());
 }
예제 #6
0
 /// <summary>
 /// Firsts the or default async.
 /// </summary>
 /// <returns>The or default async.</returns>
 /// <param name="predicate">Predicate.</param>
 public async Task <T> FirstOrDefaultAsync(Expression <Func <T, bool> > predicate)
 {
     return(await SQLClient.getInstance().GetOrCreateConnection().Table <T>().Where(predicate).FirstOrDefaultAsync());
 }
예제 #7
0
 /// <summary>
 /// Updates the async.
 /// </summary>
 /// <returns>The async.</returns>
 /// <param name="item">Item.</param>
 public async Task <int> UpdateAsync(T item)
 {
     return(await SQLClient.getInstance().GetOrCreateConnection().UpdateAsync(item));
 }
예제 #8
0
 /// <summary>
 /// Inserts all async.
 /// </summary>
 /// <returns>The all async.</returns>
 /// <param name="items">Items.</param>
 public async Task <int> InsertAllAsync(IEnumerable <T> items)
 {
     return(await SQLClient.getInstance().GetOrCreateConnection().InsertAllAsync(items));
 }
예제 #9
0
        /// <summary>
        /// Counts the async.
        /// </summary>
        /// <returns>The async.</returns>
        public async Task <int> CountAsync()
        {
            var result = await SQLClient.getInstance().GetOrCreateConnection().Table <T>().ToListAsync();

            return(result.Count);
        }
예제 #10
0
        /// <summary>
        /// Alls the async.
        /// </summary>
        /// <returns>The async.</returns>
        /// <param name="batchSize">Batch size.</param>
        /// <param name="batchNumber">Batch number.</param>
        public async Task <List <T> > AllAsync(int batchSize, int batchNumber)
        {
            var elementToSkip = batchSize * batchNumber;

            return(await SQLClient.getInstance().GetOrCreateConnection().Table <T>().Skip(elementToSkip).Take(batchSize).ToListAsync());
        }
예제 #11
0
 /// <summary>
 /// Alls the async.
 /// </summary>
 /// <returns>The async.</returns>
 public async Task <List <T> > AllAsync()
 {
     return(await SQLClient.getInstance().GetOrCreateConnection().Table <T>().ToListAsync());
 }
예제 #12
0
 /// <summary>
 /// Deletes All async.
 /// </summary>
 /// <returns>The async.</returns>
 /// <param name="id">Identifier.</param>
 public async Task <int> DeleteAllAsync()
 {
     return(await SQLClient.getInstance().GetOrCreateConnection().DeleteAllAsync <T>());
 }