当前位置: 首页>>代码示例>>C#>>正文


C# SQLiteAsyncConnection类代码示例

本文整理汇总了C#中SQLiteAsyncConnection的典型用法代码示例。如果您正苦于以下问题:C# SQLiteAsyncConnection类的具体用法?C# SQLiteAsyncConnection怎么用?C# SQLiteAsyncConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SQLiteAsyncConnection类属于命名空间,在下文中一共展示了SQLiteAsyncConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UserAccountDataSource

        public UserAccountDataSource(ISQLitePlatform platform, string dbPath)
        {
            var connectionFactory = new Func<SQLiteConnectionWithLock>(() => new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: false)));
            Db = new SQLiteAsyncConnection(connectionFactory);

            AccountUserRepository = new Repository<AccountUser>(Db);
        }
开发者ID:drasticactions,项目名称:Pureisuteshon-App,代码行数:7,代码来源:UserAccountDataSource.cs

示例2: CreateTablesAsync

        /// <summary>
        /// Creates the database tables.
        /// </summary>
        /// <param name="asyncDbConnection">The asynchronous database connection.</param>
        /// <remarks>
        /// This will insert the initial version entry.
        /// </remarks>
        public static async Task CreateTablesAsync(SQLiteAsyncConnection asyncDbConnection)
        {
            await asyncDbConnection.CreateTableAsync<DatabaseVersion>().ConfigureAwait(false);

            // sets the version to -1 (we haven't built the database yet!)
            await asyncDbConnection.InsertAsync(new DatabaseVersion()).ConfigureAwait(false);
        }
开发者ID:Luminoth,项目名称:BackpackPlanner,代码行数:14,代码来源:DatabaseVersion.cs

示例3: btnBulkInsert_Click

        private async void btnBulkInsert_Click(object sender, RoutedEventArgs e)
        {
            var Dbpath = await KnownFolders.DocumentsLibrary.CreateFolderAsync("DBFile", CreationCollisionOption.OpenIfExists);
            connection = new SQLiteAsyncConnection(string.Format("{0}\\{1}", Dbpath.Path, "Sqlitedb.db"));

            ////Create table
            connection.CreateTableAsync<User>();

            var listUser = new List<User>();
            listUser.Add(new User() { UserID = Guid.NewGuid(), DOB = DateTime.Now, Name = "senthil" });
            listUser.Add(new User() { UserID = Guid.NewGuid(), DOB = DateTime.Now, Name = "arun" });
            listUser.Add(new User() { UserID = Guid.NewGuid(), DOB = DateTime.Now, Name = "somu" });

            ////Bulk insert patient data
            connection.BulkInsert<User>(listUser);
            int i = 0;
            foreach (var item in listUser)
            {
                item.Name = item.Name + i.ToString();
                i++;
            }

            ///connection = new SQLiteAsyncConnection(string.Format("{0}\\{1}", Dbpath.Path, "Sqlitedb.db"));
            ////Bulk update patient data
            connection.BulkUpdate<User>(listUser);

            ////Bulk delete patient data
            connection.BulkDelete<User>(listUser);

        }
开发者ID:em-z,项目名称:Docs,代码行数:30,代码来源:MainPage.xaml.cs

示例4: TasksViewController

		public TasksViewController (SQLiteAsyncConnection connection, List list)
			: base (UITableViewStyle.Plain, null, true)
		{
			if (connection == null)
				throw new ArgumentNullException ("connection");
			if (list == null)
				throw new ArgumentNullException ("list");

			this.db = connection;
			this.list = list;

			var addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add, OnAddItem);
			var refreshButton = new UIBarButtonItem (UIBarButtonSystemItem.Refresh, delegate { Refresh(); });

			// attach a pull-to-refresh
			//RefreshRequested += (s, e) => Refresh();
			// add a refresh button
			NavigationItem.RightBarButtonItems = new []{ addButton, refreshButton };

			Root = new RootElement (list.Name) {
				new Section()
			};

			Refresh();
		}
开发者ID:foxanna,项目名称:SimpleLocationAlarm,代码行数:25,代码来源:TasksViewController.cs

示例5: CreateTablesAsync

        private static async Task CreateTablesAsync(SQLiteAsyncConnection asyncDbConnection)
        {
            await asyncDbConnection.CreateTableAsync<GearCollection>().ConfigureAwait(false);

            await GearCollectionGearSystem.CreateTablesAsync(asyncDbConnection).ConfigureAwait(false);
            await GearCollectionGearItem.CreateTablesAsync(asyncDbConnection).ConfigureAwait(false);
        }
开发者ID:Luminoth,项目名称:BackpackPlanner,代码行数:7,代码来源:GearCollection.cs

示例6: GetConnection

		public SQLiteAsyncConnection GetConnection ()
		{
			var sqliteFilename = "HomezigSQLite.db3";
			string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder
			var path = Path.Combine(documentsPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			//Console.WriteLine (path);
			if (!File.Exists(path))
			{
				//var s = Forms.Context.Resources.OpenRawResource(Resource.Raw.TodoSQLite);  // RESOURCE NAME ###

				// create a write stream
				//FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
				new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
				// write to the stream
				//ReadWriteStream(s, writeStream);
			}

			var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
			//var conn = new SQLite.Net.Async.SQLiteAsyncConnection(plat, path);

			var connectionFactory = new Func<SQLiteConnectionWithLock>(()=>new SQLiteConnectionWithLock(plat, new SQLiteConnectionString(path, storeDateTimeAsTicks: false)));
			var conn = new SQLiteAsyncConnection(connectionFactory);
			//conn.ExecuteAsync ("PRAGMA encoding = UTF8");
			// Return the database connection 
			return conn;
		}
开发者ID:kabsila,项目名称:HomezigXaml,代码行数:28,代码来源:SQLite_Andriod.cs

示例7: TestTimeSpan

 public async Task TestTimeSpan()
 {
     var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
     var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), true);
     var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));
     await TestAsyncDateTime(db);
 }
开发者ID:NateRickard,项目名称:SQLite.Net-PCL,代码行数:7,代码来源:TimeSpanTest.cs

示例8: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            var connFactory = new Func<SQLiteConnectionWithLock>(() =>
                new SQLiteConnectionWithLock(
                    new SQLitePlatformWin32(),
                    new SQLiteConnectionString("requests.db", false)));

            var sqlite = new SQLiteAsyncConnection(connFactory);
            var sqliteWrapper = new SQLiteAsyncConnectionImpl(sqlite);

            sqlite.CreateTableAsync<HttpRequest>().ContinueWith(_ =>
            {
                var requestHistory = new RequestHistory(sqliteWrapper);

                var historyViewModel = new HistoryViewModel(requestHistory);
                var historyView = new HistoryView(historyViewModel);
                Grid.SetColumn(historyView, 0);
                rootGrid.Children.Add(historyView);

                var requestViewModel = new RequestViewModel(requestHistory, historyViewModel.SelectedRequestObservable);
                var requestView = new RequestView(requestViewModel);
                Grid.SetColumn(requestView, 1);
                rootGrid.Children.Add(requestView);

            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
开发者ID:georgebearden,项目名称:Peticion,代码行数:28,代码来源:MainWindow.xaml.cs

示例9: StickersDataSource

        public StickersDataSource(ISQLitePlatform platform, string dbPath)
        {
            var connectionFactory = new Func<SQLiteConnectionWithLock>(() => new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: false)));
            Db = new SQLiteAsyncConnection(connectionFactory);

            StickersRepository = new Repository<StickerResponse>(Db);
        }
开发者ID:drasticactions,项目名称:Pureisuteshon-App,代码行数:7,代码来源:StickersDataSource.cs

示例10: CreateDatabaseAsync

        private static SQLiteAsyncConnection CreateDatabaseAsync()
        {
            // Create a new connection

            try
            {
                var platform = new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT();
                var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path,"Storage.SQLite");
                var connectionString = new SQLiteConnectionString(dbPath, true);
                var dbLockedCon = new SQLiteConnectionWithLock(platform ,connectionString);
            
                var db = new SQLiteAsyncConnection(() => dbLockedCon);

                 //Create the tables that do not exist
                Type[] tables = 
                { 
                       typeof(Folders)
                     , typeof(Accounts)
                     , typeof(Emails)
                     , typeof(EmailFrom)
                     , typeof(EmailSender)
                     , typeof(EmailReplyTo)
                     , typeof(Settings)
                };
                var d = db.CreateTablesAsync(tables).Result;
                return db;
            }
            catch(Exception e)
            {
                var mess = e.Message;
                throw;
            }
        }
开发者ID:KeesPolling,项目名称:Popmail,代码行数:33,代码来源:Database.cs

示例11: Database

        public Database(ISQLitePlatform platform, string databasePath)
        {
            _connectionParameters = new SQLiteConnectionString(databasePath, false);
            _sqliteConnectionPool = new SQLiteConnectionPool(platform);

            _dbConnection = new SQLiteAsyncConnection(() => _sqliteConnectionPool.GetConnection(_connectionParameters));
        }
开发者ID:nanddonet,项目名称:ToDo.PCL,代码行数:7,代码来源:Database.cs

示例12: AsyncAsTicks

 public void AsyncAsTicks ()
 {
     var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformTest());
     var sqLiteConnectionString = new SQLiteConnectionString(TestPath.GetTempFileName(), false);
     var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(sqLiteConnectionString));
     TestAsyncDateTimeOffset (db);
 }
开发者ID:NateRickard,项目名称:SQLite.Net-PCL,代码行数:7,代码来源:DateTimeOffsetTest.cs

示例13: GetAsyncConnection

 public SQLiteAsyncConnection GetAsyncConnection()
 {
     var dbPath = GetLocalFilePath("XamarinTemplate.db3");
     var connectionFactory = new Func<SQLiteConnectionWithLock>(() => new SQLiteConnectionWithLock(new SQLitePlatformWinRT(), new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: false)));
     var asyncConnection = new SQLiteAsyncConnection(connectionFactory);
     return asyncConnection;
 }
开发者ID:xamarindevelopervietnaminc,项目名称:XSqliteAsync,代码行数:7,代码来源:XSqliteServiceClient.cs

示例14: SQLiteService

 public SQLiteService()
 {
     sqliteConnection = new SQLiteAsyncConnection(() =>
     {
         return new SQLiteConnectionWithLock(new SQLitePlatformWinRT(), new SQLiteConnectionString(
          Path.Combine(ApplicationData.Current.LocalFolder.Path, dataBaseName), false));
     });
 }
开发者ID:maktub82,项目名称:sqlite-example,代码行数:8,代码来源:SQLiteService.cs

示例15: ServicoDados

 public ServicoDados()
 {
     string databasePath = Constante.DataBasePath;
     var connectionFactory = new Func<SQLiteConnectionWithLock>(() => new SQLiteConnectionWithLock(
             new SQLitePlatformWinRT(), new SQLiteConnectionString(databasePath, storeDateTimeAsTicks: false
      )));
     _conexao = new SQLiteAsyncConnection(connectionFactory);
 }
开发者ID:ishiikurisu,项目名称:S2B,代码行数:8,代码来源:ServicoDados.cs


注:本文中的SQLiteAsyncConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。