本文整理汇总了C#中SQLite.SQLiteAsyncConnection.InsertAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteAsyncConnection.InsertAsync方法的具体用法?C# SQLiteAsyncConnection.InsertAsync怎么用?C# SQLiteAsyncConnection.InsertAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteAsyncConnection
的用法示例。
在下文中一共展示了SQLiteAsyncConnection.InsertAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: SetValueAsyncInternal
private static async Task SetValueAsyncInternal(string name, string value, SQLiteAsyncConnection conn)
{
// if we don't have a connection, assume the system one...
if(conn == null)
conn = StreetFooRuntime.GetSystemDatabase();
// load an existing value...
var setting = await conn.Table<SettingItem>().Where(v => v.Name == name).FirstOrDefaultAsync();
if (setting != null)
{
// change and update...
setting.Value = value;
await conn.UpdateAsync(setting);
}
else
{
setting = new SettingItem()
{
Name = name,
Value = value
};
// save...
await conn.InsertAsync(setting);
}
}
示例3: btnOK_Click
private async void btnOK_Click(object sender, RoutedEventArgs e)
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "people.db"), true);
Person person = new Person
{
DoctorName = watermarkTextBox.Text,
Date = datepick.ValueString,
Time = timepick.ValueString
};
await conn.InsertAsync(person);
//My_Medi.ViewModels.MainViewModel veiw = new ViewModels.MainViewModel();
//veiw.LoadData();
DataContext = App.ViewModel;
App.ViewModel.Items.Clear();
App.ViewModel.LoadData();
NavigationService.GoBack();
}
示例4: AddVisit
public async Task<int> AddVisit(Visit visit) {
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(this.dbPath);
if (visit.ID > 0) {
return await conn.UpdateAsync(visit);
}
return await conn.InsertAsync(visit);
}
示例5: WriteMessage
public async Task WriteMessage(string messageString)
{
var message = new Message {MessageString = messageString};
var connection = new SQLiteAsyncConnection(_databasePath);
await connection.InsertAsync(message);
}
示例6: Button_Click_2
private async void Button_Click_2(object sender, RoutedEventArgs e)
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(ApplicationData.Current.LocalFolder.Path + "\\people.db");
Person person = new Person
{
Name = "张三",
Work = "程序员"
};
await conn.InsertAsync(person);
Person person2 = new Person
{
Name = "李四",
Work = "设计师"
};
await conn.InsertAsync(person2);
MessageBox.Show("插入数据成功");
}
示例7: InsertOrganization
public async static Task InsertOrganization(Organization organization)
{
SQLiteAsyncConnection sqlConnection = new SQLiteAsyncConnection(DbHelper.DB_PATH);
var collectionItem = await sqlConnection.Table<Organization>().Where(x => x.Id == organization.Id).FirstOrDefaultAsync();
if (collectionItem == null)
{
await sqlConnection.InsertAsync(organization);
}
}
示例8: AddOrUpdateCounterAsync
public async Task AddOrUpdateCounterAsync(Counter counter)
{
var connection = new SQLiteAsyncConnection(_dbPath);
if (counter.Id == 0)
await connection.InsertAsync(counter);
else
await connection.InsertOrReplaceAsync(counter);
OnCountersChanged();
}
示例9: insertProduct
public static async void insertProduct(Product product)
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(PRODUCTS_TABLE);
await conn.CreateTableAsync<Product>();
await conn.InsertAsync(product);
}
示例10: addFavouriteStop
// Favourites
public static async Task<int> addFavouriteStop(OCDirection direction)
{
int result = 0;
String path = ApplicationData.Current.LocalFolder.Path + "/OCTranspo.sqlite";
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(path);
await conn.InsertAsync(direction).ContinueWith((t) =>
{
result = t.Result;
});
return result;
}
示例11: Button_Click
private async void Button_Click(object sender, RoutedEventArgs e)
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection("institutionFinder.db");
await conn.InsertAsync(newColleges);
// Add to the user list
college.Add(newColleges);
// Refresh user list
searchColleges.ItemsSource = null;
searchColleges.ItemsSource = college;
}
示例12: 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);
}
}
示例13: Button_Click_2
private async void Button_Click_2(object sender, RoutedEventArgs e)
{
var path = ApplicationData.Current.LocalFolder.Path + @"\Users.db";
var db = new SQLiteAsyncConnection(path);
var data = new User
{
name=txt_name.Text,
email=txt_email.Text
};
int i = await db.InsertAsync(data);
}
示例14: ConnectionInit
/// <summary>
/// Initialise the Database connection and creates tables/default values if not existant.
/// </summary>
private async void ConnectionInit()
{
//Connection init
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
Database = new SQLite.SQLiteAsyncConnection(dbPath);
//Create tables if not exists
await Database.CreateTablesAsync(new Account().GetType(), new DatabaseRoute().GetType(), new DatabasePOI().GetType());
await Database.ExecuteAsync("create table if not exists \"RouteBinds\"(\"RouteID\" integer,\"WaypointID\" integer);", new object[] { });
//Set default Admin Admin password
var result = await Database.ExecuteScalarAsync<String>("Select Gebruikersnaam From Account WHERE Gebruikersnaam = ? AND Password = ?", new object[] { "Admin", "Admin" });
if(result == null)
await Database.InsertAsync(new Account("Admin", "Admin"));
}
示例15: IncrementCounterAsync
public async Task IncrementCounterAsync(Counter counter)
{
var connection = new SQLiteAsyncConnection(_dbPath);
counter.Value++;
await AddOrUpdateCounterAsync(counter);
var history = new CounterIncrementHistory
{
CounterId = counter.Id,
IncrementDateTimeUtc = DateTime.UtcNow
};
await connection.InsertAsync(history);
}