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


C# SQLiteAsyncConnection.InsertAsync方法代码示例

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


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

示例1: 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

示例2: PrepareDb

        private void PrepareDb()
        {
            SQLiteAsyncConnection connection = new SQLiteAsyncConnection(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "TestDb.sqlite"));

            connection.DropTableAsync<Product>();
            connection.CreateTableAsync<Product>();

            connection.InsertAsync(new Product { Name = "Product 1", Serial = "123456" });

        }
开发者ID:piccoloaiutante,项目名称:WP8TestingExample,代码行数:10,代码来源:DbServiceFixture.cs

示例3: TestAsyncDateTime

        private async Task TestAsyncDateTime(SQLiteAsyncConnection db)
        {
            await db.CreateTableAsync<TestDb>();

            var val1 = new TestDb
            {
                Time = new TimeSpan(1000),
            };
            await db.InsertAsync(val1);
            TestDb val2 = await db.GetAsync<TestDb>(val1.Id);
            Assert.AreEqual(val1.Time, val2.Time);
        }
开发者ID:NateRickard,项目名称:SQLite.Net-PCL,代码行数:12,代码来源:TimeSpanTest.cs

示例4: TestAsyncDateTime

        void TestAsyncDateTime(SQLiteAsyncConnection db)
        {
            db.CreateTableAsync<TestObj> ().Wait ();

            TestObj o, o2;

            //
            // Ticks
            //
            o = new TestObj {
                ModifiedTime = new DateTime (2012, 1, 14, 3, 2, 1, 234),
            };
            db.InsertAsync (o).Wait ();
            o2 = db.GetAsync<TestObj> (o.Id).Result;
            Assert.AreEqual (o.ModifiedTime, o2.ModifiedTime);
        }
开发者ID:FatJohn,项目名称:sqlite-net,代码行数:16,代码来源:DateTimeTest.cs

示例5: TestAsyncDateTime

        private async Task TestAsyncDateTime(SQLiteAsyncConnection db)
        {
            await db.CreateTableAsync<TestObj>();

            TestObj o, o2;

            //
            // Ticks
            //
            o = new TestObj
            {
                ModifiedTime = new DateTime(2012, 1, 14, 3, 2, 1),
            };
            await db.InsertAsync(o);
            o2 = await db.GetAsync<TestObj>(o.Id);
            Assert.AreEqual(o.ModifiedTime, o2.ModifiedTime);
        }
开发者ID:happynik,项目名称:SQLite.Net-PCL,代码行数:17,代码来源:DateTimeTest.cs

示例6: TestAsyncDateTime

        private async Task TestAsyncDateTime(SQLiteAsyncConnection db, bool storeDateTimeAsTicks)
        {
            await db.CreateTableAsync<TestObj>();

            var org = new TestObj
            {
                Time1 = DateTime.UtcNow,
                Time2 = DateTime.Now,
            };
            await db.InsertAsync(org);
            var fromDb = await db.GetAsync<TestObj>(org.Id);
            Assert.AreEqual(fromDb.Time1.ToUniversalTime(), org.Time1.ToUniversalTime());
            Assert.AreEqual(fromDb.Time2.ToUniversalTime(), org.Time2.ToUniversalTime());

            Assert.AreEqual(fromDb.Time1.ToLocalTime(), org.Time1.ToLocalTime());
            Assert.AreEqual(fromDb.Time2.ToLocalTime(), org.Time2.ToLocalTime());
        }
开发者ID:Reza1024,项目名称:SQLite.Net-PCL,代码行数:17,代码来源:DateTimeTest.cs

示例7: TestAsyncDateTime

        private async Task TestAsyncDateTime(SQLiteAsyncConnection db, bool storeDateTimeAsTicks)
        {
            await db.CreateTableAsync<TestObj>();

            TestObj o, o2;

            //
            // Ticks
            //
            o = new TestObj
            {
                ModifiedTime = DateTime.UtcNow,
            };
            await db.InsertAsync(o);
            o2 = await db.GetAsync<TestObj>(o.Id);
            Assert.AreEqual(o.ModifiedTime, o2.ModifiedTime.ToUniversalTime());

            var expectedTimeZone = storeDateTimeAsTicks ? DateTimeKind.Utc : DateTimeKind.Local;
            Assert.AreEqual(o2.ModifiedTime.Kind, expectedTimeZone);
        }
开发者ID:jamesottaway,项目名称:SQLite.Net-PCL,代码行数:20,代码来源:DateTimeTest.cs

示例8: InsertAsync

 public Task<int> InsertAsync(SQLiteAsyncConnection conn)
 {
     return conn.InsertAsync(this);
 }
开发者ID:mbrit,项目名称:callisto,代码行数:4,代码来源:Entity.cs

示例9: AddFavoriteAsync

        public static async Task AddFavoriteAsync(Stop stop)
        {
            //var _favoritesAsyncConnection = new SQLiteAsyncConnection(favoriteDbPath);
            favoritesConnection = new SQLiteAsyncConnection(() => DbConnection(favoriteDbPath));

            await favoritesConnection.InsertAsync(new Favorite
                {
                    Name = stop.StopName,
                    Routes = stop.Routes,
                    Tags = stop.StopTags,
                    Lat = stop.Latitude,
                    Lon = stop.Longitude
                });

            await LoadFavoritesAsync();
        }
开发者ID:nexDevelopment,项目名称:nexMUNI,代码行数:16,代码来源:DatabaseHelper.cs

示例10: Add

 public Task Add(BackgroundTrackItem track)
 {
     connectionLock = new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(DbPath, false));
     var connection = new SQLiteAsyncConnection(() => connectionLock);
     return connection.InsertAsync(track);
 }
开发者ID:robUx4,项目名称:vlc-winrt,代码行数:6,代码来源:BackgroundTrackDatabase.cs


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