本文整理汇总了C#中SQLite.SQLiteAsyncConnection.CreateTableAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteAsyncConnection.CreateTableAsync方法的具体用法?C# SQLiteAsyncConnection.CreateTableAsync怎么用?C# SQLiteAsyncConnection.CreateTableAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteAsyncConnection
的用法示例。
在下文中一共展示了SQLiteAsyncConnection.CreateTableAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
private async void Create()
{
Connection = new SQLiteAsyncConnection(dbpath);
// create all tables
Connection.CreateTableAsync<SQLite.Task>();
}
示例2: CheckAndCreateDatabase
public async static void CheckAndCreateDatabase()
{
if (!await FileUtils.CheckFileExists(DbHelper.DB_NAME))
{
System.Diagnostics.Debug.WriteLine("creating tables");
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(DB_PATH);
await conn.CreateTableAsync<Organization>();
await conn.CreateTableAsync<Counter>();
await conn.CreateTableAsync<Menu>();
await conn.CreateTableAsync<Item>();
}
else
{
System.Diagnostics.Debug.WriteLine("tables exist");
}
}
示例3: loadData
private async void loadData()
{
//SQLiteAsyncConnection conn1 = new SQLiteAsyncConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true);
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(System.IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true);
conn.DropTableAsync<SampleAppointment>();
await conn.CreateTableAsync<SampleAppointment>();
DateTime temp = DateTime.Now;
DateTime start = DateTime.Parse("06/08/2013 6:00 PM");
DateTime end = DateTime.Parse("06/09/2013 6:00 PM");
SampleAppointment appointment1 = new SampleAppointment
{
Subject = "MACF - App Camp",
AdditionalInfo = "BRTN 291, RSVP Reguired",
StartDate = start,
EndDate = end
};
conn.InsertAsync(appointment1);
SampleAppointment appointment2 = new SampleAppointment
{
StartDate = DateTime.Now.AddMinutes(30),
EndDate = DateTime.Now.AddHours(1),
Subject = "Appointment 376",
AdditionalInfo = "Info 3"
};
conn.InsertAsync(appointment2);
start = DateTime.Parse("06/05/2013 5:00 PM");
end = DateTime.Parse("06/05/2013 6:00 PM");
SampleAppointment appointment3 = new SampleAppointment
{
StartDate = DateTime.Now.AddHours(2),
EndDate = DateTime.Now.AddHours(3),
Subject = "Appointment uhy4",
AdditionalInfo = "Info 4"
};
conn.InsertAsync(appointment3);
SampleAppointment appointment4 = new SampleAppointment
{
Subject = "Malaysian Night",
AdditionalInfo = "STEW Common, Members Only",
StartDate = start,
EndDate = end
};
conn.InsertAsync(appointment4);
//this.OnDataLoaded();
}
示例4: CreateDatabase
public async void CreateDatabase()
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "User.db"), true);
await conn.CreateTableAsync<User>();
SQLiteAsyncConnection conn1 = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "Appointment.db"), true);
await conn1.CreateTableAsync<Appointment>();
}
示例5: 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);
}
示例6: connectDB
async Task<int> connectDB()
{
var path = Windows.Storage.ApplicationData.Current.LocalFolder.Path + @"\beyondvincent.db";
db = new SQLiteAsyncConnection(path);
await db.DropTableAsync<User>();
await db.CreateTableAsync<User>();
return 0;
}
示例7: App
public App (string dbPath)
{
// set up the database
db = new SQLiteAsyncConnection (dbPath);
db.CreateTableAsync<TaskItem> ().Wait ();
// The root page of your application
MainPage = new NavigationPage (new TasksPage (db));
}
示例8: ConnectToDatabase
public async static Task<SQLiteAsyncConnection> ConnectToDatabase()
{
var databaseConnection = new SQLiteAsyncConnection(DatabaseFileName, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.NoMutex);
var version = "1.3";
var oldVersion = ApplicationSettings.DatabaseCreationVersion.Read();
if (oldVersion != version)
{
await databaseConnection.CreateTableAsync<Song>();
await databaseConnection.CreateTableAsync<SongGenre>();
await databaseConnection.CreateTableAsync<Genre>();
await databaseConnection.CreateTableAsync<CachedAlbumCover>();
await databaseConnection.CreateTableAsync<CurrentPlaylistSong>();
await databaseConnection.CreateTableAsync<SavedPlaylistSong>();
await databaseConnection.CreateTableAsync<SavedPlaylist>();
necessaryUpdatesForLibrary = new List<Func<MusicLibrary, Task>>();
ApplicationSettings.IsDatabaseSettingUp.Save(true);
if (oldVersion == "1.0" || oldVersion == "1.1" || oldVersion == "1.3")
{
necessaryUpdatesForLibrary.Add(async library =>
{
foreach (var song in library.Songs)
{
try
{
var storageFile = await StorageFile.GetFileFromPathAsync(song.FileName);
TagLib.Tag tag = null;
using (var stream = await storageFile.OpenStreamForReadAsync())
{
tag = await Task<TagLib.File>.Run(() =>
{
try
{
return TagLib.File.Create(new TagLib.StreamFileAbstraction(storageFile.Name, stream, null)).Tag;
}
catch { return null; }
});
}
if (tag != null)
{
library.localLibrarySource.UpdateSongMetadata(tag, song);
await library.databaseConnection.UpdateAsync(song);
}
}
catch { }
}
});
}
necessaryUpdatesForLibrary.Add(async library => { ApplicationSettings.DatabaseCreationVersion.Save(version); await Task.Delay(0); });
}
return databaseConnection;
}
示例9: createFavouritesTable
private static async void createFavouritesTable()
{
String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
var count = await conn.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='OCDirection'");
if (count == 0)
{
await conn.CreateTableAsync<OCDirection>();
}
}
示例10: insertProduct
public static async void insertProduct(Product product)
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(PRODUCTS_TABLE);
await conn.CreateTableAsync<Product>();
await conn.InsertAsync(product);
}
示例11: getExamsAsync
public static async Task<List<Exam>> getExamsAsync()
{
if (exams.Count != 0)
{
return exams;
}
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Windows.Storage.ApplicationData.Current.LocalFolder.Path + "\\Data.db");
await conn.CreateTableAsync<Exam>();
exams = await conn.Table<Exam>().OrderBy(exam => exam.ExamTime).ToListAsync();
return exams;
}
示例12: HouseImageCacheRepository
public HouseImageCacheRepository ()
{
string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
db = new SQLiteAsyncConnection (System.IO.Path.Combine (folder, "houseImages.db"));
// db.DropTableAsync<HouseImages> ().ContinueWith (t => {
// Console.WriteLine ("Table Dropped!");
// });
db.CreateTableAsync<HouseImages>().ContinueWith (t => {
Console.WriteLine ("Table created!");
});
}
示例13: Button_Click_1
private async void Button_Click_1(object sender, RoutedEventArgs e)
{
try
{
var path = ApplicationData.Current.LocalFolder.Path + @"\Users.db";
var db = new SQLiteAsyncConnection(path);
await db.CreateTableAsync<User>();
}
catch (Exception)
{ }
//Button_Click_1.visibility = Visibility.Collapsed;
}
示例14: PrepareDatabase
private async Task PrepareDatabase()
{
var path = Path.Combine(Path.GetDirectoryName(typeof(TodoService).Assembly.Location), "todos.db");
if (File.Exists(path))
File.Delete(path);
var db = new SQLiteAsyncConnection(path);
await db.CreateTableAsync<TodoItem>();
var count = await db.InsertAllAsync(Todos);
Assert.Equal(Todos.Count, count);
}
示例15: createSettingsTable
private static async void createSettingsTable()
{
String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
var count = await conn.ExecuteScalarAsync<int>("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='OCSettings'");
if (count == 0)
{
await conn.CreateTableAsync<OCSettings>();
OCSettings settings = OCSettings.newOCSettings(500);
settings.id = 1;
await conn.InsertAsync(settings);
}
}