コード例 #1
0
ファイル: DaoCommon.cs プロジェクト: YuhichYOC/rereSqliteCS
 protected bool TableExists()
 {
     using var accessor = new SqliteAccessor {
               DataSource  = AppBehind.Get.DBFilePath,
               Password    = AppBehind.Get.Password,
               QueryString = GetQueryTableExists()
           };
     accessor.Open();
     return(0 < (long)accessor.ExecuteScalar(accessor.CreateCommand()));
 }
コード例 #2
0
        public static void Register(
            bool insert,
            string key,
            string filePath,
            string fileName,
            List <object> tags
            )
        {
            using var accessor = new SqliteAccessor {
                      DataSource  = AppBehind.Get.DBFilePath,
                      Password    = AppBehind.Get.Password,
                      QueryString = insert ? INSERT : UPDATE
                  };
            accessor.Open();
            var transaction = accessor.Begin();

            try {
                var command = accessor.CreateCommand();
                command.Parameters.AddWithValue(@"@key", key);
                command.Parameters.AddWithValue(@"@fileName", fileName);
                command.Parameters.AddWithValue(@"@length", new FileInfo(filePath).Length);
                using var inputStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                accessor.WriteBlob(
                    inputStream,
                    @"BINARY_STORAGE",
                    @"VALUE",
                    (long)accessor.ExecuteScalar(command)
                    );
                BinaryTags.Register(accessor, key, tags);
                transaction.Commit();
            }
            catch (Exception) {
                transaction.Rollback();
                throw;
            }
        }