本文整理汇总了C#中SQLiteAsyncConnection.CreateTableAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteAsyncConnection.CreateTableAsync方法的具体用法?C# SQLiteAsyncConnection.CreateTableAsync怎么用?C# SQLiteAsyncConnection.CreateTableAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLiteAsyncConnection
的用法示例。
在下文中一共展示了SQLiteAsyncConnection.CreateTableAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeDataStore
public async Task InitializeDataStore ()
{
_isInitialized = true;
// Get the platform-specific database info
IPlatform dataPlatform = DependencyService.Get<IPlatform> ();
// Create the connection
_sqliteConn = new SQLiteAsyncConnection (() => new SQLiteConnectionWithLock (dataPlatform.OSPlatform,
new SQLiteConnectionString (dataPlatform.DatabasePath, true)));
// Create the tables
await _sqliteConn.CreateTableAsync<Cheese> ().ConfigureAwait (false);
await _sqliteConn.CreateTableAsync<Rating> ().ConfigureAwait (false);
}
示例2: Init
public async void Init()
{
var connectionFactory = Mvx.Resolve<IMvxSqliteConnectionFactory>();
_connection = connectionFactory.GetAsyncConnection("GastoCertoBD");
await _connection.CreateTableAsync<PrevisaoGasto>();
}
示例3: 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());
}
示例4: 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);
}
示例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);
}
示例6: 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);
}
示例7: UnicodePathsAsync
public void UnicodePathsAsync()
{
var path = Path.GetTempFileName() + UnicodeText;
var db = new SQLiteAsyncConnection(path, true);
db.CreateTableAsync<OrderLine>().Wait();
Assert.That(new FileInfo(path).Length, Is.GreaterThan(0), path);
}
示例8: 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" });
}
示例9: UnicodePathsAsync
public void UnicodePathsAsync()
{
string path = Path.GetTempFileName() + UnicodeText;
var sqLiteConnectionPool = new SQLiteConnectionPool(new SQLitePlatformWin32());
var db = new SQLiteAsyncConnection(() => sqLiteConnectionPool.GetConnection(new SQLiteConnectionString(path, true)));
db.CreateTableAsync<OrderLine>().Wait();
Assert.That(new FileInfo(path).Length, Is.GreaterThan(0), path);
}
示例10: UnicodePathsAsync
public async Task UnicodePathsAsync()
{
var fileName = TestPath.CreateDefaultTempFilename() + UnicodeText + ".db";
var filePath = TestPath.CreateTemporaryDatabase(fileName);
var db = new SQLiteAsyncConnection(() => new SQLiteConnectionWithLock(new SQLitePlatformTest(), new SQLiteConnectionString(filePath, true)));
await db.CreateTableAsync<OrderLine>();
Assert.That(filePath.Length, Is.GreaterThan(0), fileName);
}
示例11: 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);
}
示例12: SQLiteLoggerAdapter
public SQLiteLoggerAdapter(LoggerSettings LoggerSettings_,SQLiteAsyncConnection SQLiteLogConnection_)
{
LoggerSettings = LoggerSettings_;
SQLiteLogConnection = SQLiteLogConnection_;
var t = SQLiteLogConnection.CreateTableAsync<LogMessage>().Result;
if (LoggerSettings.DeleteMessagesOnStart)
{
SQLiteLogConnection.DeleteAllAsync<LogMessage>();
}
}
示例13: PersonRepository
public PersonRepository(ISQLitePlatform sqlitePlatform, string dbPath)
{
//initialize a new SQLiteConnection
if (dbConn == null)
{
var connectionFunc = new Func<SQLiteConnectionWithLock>(() =>
new SQLiteConnectionWithLock
(
sqlitePlatform,
new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: false)
));
dbConn = new SQLiteAsyncConnection(connectionFunc);
dbConn.CreateTableAsync<Person>();
}
}
示例14: 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);
}
示例15: 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);
}