本文整理汇总了C#中ZkData.ZkDataContext.SaveChangesAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ZkDataContext.SaveChangesAsync方法的具体用法?C# ZkDataContext.SaveChangesAsync怎么用?C# ZkDataContext.SaveChangesAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZkData.ZkDataContext
的用法示例。
在下文中一共展示了ZkDataContext.SaveChangesAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoreChatHistory
public async Task StoreChatHistory(Say say)
{
using (var db = new ZkDataContext()) {
var historyEntry = new LobbyChatHistory();
historyEntry.SetFromSay(say);
db.LobbyChatHistories.Add(historyEntry);
await db.SaveChangesAsync();
}
}
示例2: ProcessEvent
async Task ProcessEvent(TraceEventType type, string text)
{
using (var db = new ZkDataContext()) {
db.LogEntries.Add(new LogEntry() { Time = DateTime.UtcNow, Message = text, TraceEventType = type });
await db.SaveChangesAsync();
}
// write error and critical logs to server
if (type == TraceEventType.Error || type == TraceEventType.Critical) {
var say = new Say() { Place = SayPlace.Channel, Target = "zkerror", Text = text, User = GlobalConst.NightwatchName, Time=DateTime.UtcNow};
if (ZkLobbyServer != null) {
// server runnin, flush queue and add new say
Say history;
while (queue.TryDequeue(out history)) await ZkLobbyServer.GhostSay(history);
await ZkLobbyServer.GhostSay(say);
} else queue.Enqueue(say); // server not running (stuff intiializing) store in queueu
}
}