本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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();
}
示例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: 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;
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}
}
示例11: Database
public Database(ISQLitePlatform platform, string databasePath)
{
_connectionParameters = new SQLiteConnectionString(databasePath, false);
_sqliteConnectionPool = new SQLiteConnectionPool(platform);
_dbConnection = new SQLiteAsyncConnection(() => _sqliteConnectionPool.GetConnection(_connectionParameters));
}
示例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);
}
示例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;
}
示例14: SQLiteService
public SQLiteService()
{
sqliteConnection = new SQLiteAsyncConnection(() =>
{
return new SQLiteConnectionWithLock(new SQLitePlatformWinRT(), new SQLiteConnectionString(
Path.Combine(ApplicationData.Current.LocalFolder.Path, dataBaseName), false));
});
}
示例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);
}