本文整理汇总了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);
}
示例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" });
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例8: InsertAsync
public Task<int> InsertAsync(SQLiteAsyncConnection conn)
{
return conn.InsertAsync(this);
}
示例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();
}
示例10: Add
public Task Add(BackgroundTrackItem track)
{
connectionLock = new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(DbPath, false));
var connection = new SQLiteAsyncConnection(() => connectionLock);
return connection.InsertAsync(track);
}