本文整理汇总了C#中SQLite.SQLiteAsyncConnection.InsertOrReplaceAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteAsyncConnection.InsertOrReplaceAsync方法的具体用法?C# SQLiteAsyncConnection.InsertOrReplaceAsync怎么用?C# SQLiteAsyncConnection.InsertOrReplaceAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.SQLiteAsyncConnection
的用法示例。
在下文中一共展示了SQLiteAsyncConnection.InsertOrReplaceAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: SaveAsync
public new Task<int> SaveAsync(SQLiteAsyncConnection db)
{
return db.InsertOrReplaceAsync(this);
}
示例3: SaveAsync
public virtual Task<int> SaveAsync(SQLiteAsyncConnection db)
{
return Status == Status.Valid ? db.InsertOrReplaceAsync(this) : null;
}
示例4: Parse
/// <summary>
/// Load transaction data and store in local sqlite db
/// </summary>
/// <param name="apiKey"></param>
/// <param name="vCode"></param>
/// <param name="charID"></param>
/// <returns></returns>
public async static Task<bool> Parse(string apiKey, string vCode, string charID)
{
// open DB
var sqliteTransactionData = new SQLiteAsyncConnection(charID + ".sqlite");
await sqliteTransactionData.CreateTableAsync<Transaction>();
//await sqliteTransactionData.ExecuteAsync("ATTACH DATABASE '" + Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "\\Assets\\Data\\static.sqlite' AS Static");
// build request string
String request = "https://api.eveonline.com/char/WalletTransactions.xml.aspx";
request += "?keyID=" + apiKey;
request += "&vCode=" + vCode;
request += "&characterID=" + charID;
// load data as xml string
HttpResponseMessage response = await new HttpClient().GetAsync(request);
string xml_data = await response.Content.ReadAsStringAsync();
// parse as xml and fetch data
XDocument transactiondata = XDocument.Parse(xml_data);
var transactions = from transaction in transactiondata.Descendants("row")
select new
{
TransactionDateTime = transaction.Attribute("transactionDateTime").Value ?? "",
TransactionID = transaction.Attribute("transactionID").Value ?? "",
Quantity = transaction.Attribute("quantity").Value ?? "",
TypeName = transaction.Attribute("typeName").Value ?? "",
TypeID = transaction.Attribute("typeID").Value ?? "",
Price = transaction.Attribute("price").Value ?? "",
ClientID = transaction.Attribute("clientID").Value ?? "",
ClientName = transaction.Attribute("clientName").Value ?? "",
StationID = transaction.Attribute("stationID").Value ?? "",
StationName = transaction.Attribute("stationName").Value ?? "",
TransactionType = transaction.Attribute("transactionType").Value ?? "",
TransactionFor = transaction.Attribute("transactionFor").Value ?? "",
JournalTransactionID = transaction.Attribute("journalTransactionID").Value ?? "",
ClientTypeID = transaction.Attribute("clientTypeID").Value ?? ""
};
// create new transaction for each record
foreach (var transaction in transactions)
{
Transaction ta = new Transaction();
ta.Time = DateTime.Parse(transaction.TransactionDateTime);
ta.TransactionID = Int64.Parse(transaction.TransactionID);
ta.Quantity = Int32.Parse(transaction.Quantity);
ta.TypeName = transaction.TypeName;
ta.TypeID = Int32.Parse(transaction.TypeID);
ta.PricePerUnit = double.Parse(transaction.Price);
ta.ClientID = Int32.Parse(transaction.ClientID);
ta.ClientName = transaction.ClientName;
ta.StationID = Int32.Parse(transaction.StationID);
ta.StationName = transaction.StationName;
ta.BuyOrder = transaction.TransactionType.Equals("buy") ? true : false;
ta.TaFor = transaction.TransactionFor;
ta.JournalTransactionID = Int64.Parse(transaction.JournalTransactionID);
ta.ClientTypeID = Int32.Parse(transaction.ClientTypeID);
TransactionInformation info = await TransactionInformation.Load(ta.TypeID);
ta.MarketGroupID = info.MarketGroupIDTopLevel;
ta.MarketGroupName = info.MarketGroupNameTopLevel;
//TODO: Insert or ignore to make it faster?
await sqliteTransactionData.InsertOrReplaceAsync(ta);
}
return false;
}