本文整理汇总了C#中System.Data.SQLite.SQLiteConnection.LoadExtension方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.LoadExtension方法的具体用法?C# SQLiteConnection.LoadExtension怎么用?C# SQLiteConnection.LoadExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.LoadExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
/// <summary>
/// Loads mod_spatialite.dll on the given connection
/// </summary>
public static void Load(SQLiteConnection conn)
{
lock (Lock)
{
//Need to work out where the file is and add it to the path so it can load all the other dlls too
if (!_haveSetPath)
{
var spatialitePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), (Environment.Is64BitProcess ? "x64" : "x86"), "spatialite");
Environment.SetEnvironmentVariable("PATH", spatialitePath + ";" + Environment.GetEnvironmentVariable("PATH"));
_haveSetPath = true;
}
}
conn.LoadExtension("mod_spatialite.dll");
}
示例2: Main
static void Main(string[] args)
{
string mod_spatialite_folderPath = "mod_spatialite-4.3.0a-win-amd64";
if (is64bitProcess())
{
Console.WriteLine("64bit process");
mod_spatialite_folderPath = "mod_spatialite-4.3.0a-win-amd64";
}
else if(is32bitProcess())
{
Console.WriteLine("32bit process");
mod_spatialite_folderPath = "mod_spatialite-4.3.0a-win-x86";
}
//using relative path, cannot use absolute path, dll load will fail
//string mod_spatialite_dllPath = @"mod_spatialite-4.3.0a-win-amd64\mod_spatialite";
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine) + ";" + mod_spatialite_folderPath;
Environment.SetEnvironmentVariable("Path", path, EnvironmentVariableTarget.Process);
string sqlitePath = "_BCC_replication.sqlite";
//select 'geometry::STGeomFromWKB(0x' || hex(ST_AsBinary(geometry)) || ', 28356) ' as geometry2 from qpp_airport_ols;
string sqliteConnectionString = getSqliteV3ConnectionString(sqlitePath);
using (var sqliteConnection = new SQLiteConnection(sqliteConnectionString))
{
sqliteConnection.Open();
Console.WriteLine("Load-ing mod_spatialite");
string mod_spatialite_dllPath = mod_spatialite_folderPath + @"\mod_spatialite";
sqliteConnection.LoadExtension(mod_spatialite_dllPath);
Console.WriteLine("Load-ed mod_spatialite");
sqliteConnection.Execute("update qpp_airport_ols set lga_code = 111122 where ogc_fid = 2;");
}
Console.ReadLine();
}