本文整理汇总了C#中SQLiteConnection.GetTableInfo方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.GetTableInfo方法的具体用法?C# SQLiteConnection.GetTableInfo怎么用?C# SQLiteConnection.GetTableInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.GetTableInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTableBySql
public static void CreateTableBySql(SQLiteConnection conn, string tableName, string sql)
{
try
{
if (conn.GetTableInfo(tableName).Count == 0)
{
var cmd = conn.CreateCommand(sql);
var ret = cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Logger.Log(LogType.Exception, sql, ex);
}
}
示例2: Init
public static void Init(List<LogOutputDirections> outputDirectionList)
{
_outputDirectionList = outputDirectionList;
if (_outputDirectionList.Contains(LogOutputDirections.LocalFile))
{
Task.Run(async () =>
{
while (true)
{
if (_logCache4File.Count == 0)
{
await Task.Delay(TimeSpan.FromSeconds(10));
continue;
}
var tmpLogList = new List<string>();
while (_logCache4File.Count > 0)
{
var lineLog = _logCache4File.Take();
tmpLogList.Add(lineLog);
}
var localFolder = ApplicationData.Current.LocalFolder;
var nowDateStr = DateTime.Now.ToString("yyMMdd");
try
{
var file = await localFolder.CreateFileAsync($"{nowDateStr}.log", CreationCollisionOption.OpenIfExists);
await FileIO.AppendLinesAsync(file, tmpLogList);
}
catch (Exception ex)
{
Log.e($"Log.Init file writing ... ex : \n{ex}");
}
}
});
}
if (_outputDirectionList.Contains(LogOutputDirections.LocalSqliteDb))
{
Task.Run(async () =>
{
while (true)
{
if (_logCache4Sqlite.Count == 0)
{
await Task.Delay(TimeSpan.FromSeconds(10));
continue;
}
var tmpLogList = new List<SqliteLogEntity>();
while (_logCache4Sqlite.Count > 0)
{
var log = _logCache4Sqlite.Take();
tmpLogList.Add(log);
}
using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), Path.Combine(ApplicationData.Current.LocalFolder.Path, "log.sqlite")))
{
var tiList = db.GetTableInfo(typeof(SqliteLogEntity).Name);
if (!tiList.Any())
{
db.CreateTable<SqliteLogEntity>();
}
var list = db.Table<SqliteLogEntity>().Take(10).ToList();
db.InsertAll(tmpLogList);
}
}
});
}
}