1. 从https://github.com/qingask/PetaPoco.NetCore下载源文件压缩包
  2. 解压出文件PetaPoco.Multiple.cs、PetaPoco.NetCore.cs
  3. 放置System.Data.SQLite.dll文件到bin文件,这个需要从SQLite官方获取对应框架集级对应位文件,应该可以直接通过NuGet获取。
  4. 方法1:
    1. 增加DbProviderFactories类,向PetaPoco注入SQLite实例

      public static class DbProviderFactories
      { internal static readonly Dictionary<string, DbProviderFactory> Configs = new Dictionary<string, DbProviderFactory>(); static DbProviderFactories()
      {
      RegisterFactory("Microsoft.Data.Sqlite", SQLiteFactory.Instance);
      } public static DbProviderFactory GetFactory(string providerInvariantName)
      {
      if (Configs.ContainsKey(providerInvariantName))
      {
      return Configs[providerInvariantName];
      }
      return null;
      } public static void RegisterFactory(string providerInvariantName, DbProviderFactory factory)
      {
      if (Configs.ContainsKey(providerInvariantName))
      {
      Configs[providerInvariantName] = factory;
      }
      else
      {
      Configs.Add(providerInvariantName, factory);
      }
      } public static IEnumerable<string> GetFactoryProviderNames()
      {
      return Configs.Keys.ToArray();
      }
      }
    2. 配置web.config
      <add name="PetaPocoConn" connectionString="Data Source=|DataDirectory|Demo.db"/>
    3. 链接语法 
      var db=new Database(new SQLiteConnection(ConfigurationManager.ConnectionStrings["PetaPocoConn"].ConnectionString));
  5.   方法2:
    1.   配置web.config

       <system.data>
      <DbProviderFactories>
      <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      </DbProviderFactories>
      </system.data>
    2. 链接字符串:
      <connectionStrings>
      <add name="PetaPocoConn" connectionString="Data Source=|DataDirectory|Demo.db" providerName="System.Data.SQLite" />
      </connectionStrings>
    3. 辅助类:
          public static class DbScoure
      {
      public static Database SqliteDataBase()
      {
      var conn = ConfigurationManager.ConnectionStrings["PetaPocoConn"];
      return new Database(conn.ConnectionString, conn.ProviderName);
      }
      }
      调用方式:
      var db=DbScoure.SqliteDataBase();

整理两个PetaPoco连接SQLite数据库的方法的更多相关文章

  1. Python3实现连接SQLite数据库的方法

    本文实例讲述了Python3实现连接SQLite数据库的方法,对于Python的学习有不错的参考借鉴价值.分享给大家供大家参考之用.具体方法如下: 实例代码如下: ? 1 2 3 4 5 6 7 8 ...

  2. Navicat 连接Sqlite数据库的方法和步骤

    1.打开Navicat,进行如下操作. 2.在弹出的新建连接对话框中输入正确的信息,点击“确定”按钮. 3.可见如下

  3. Adobe AIR中使用Flex连接Sqlite数据库(1)(创建数据库和表,以及同步和异步执行模式)

    系列文章导航 Adobe AIR中使用Flex连接Sqlite数据库(1)(创建数据库和表) Adobe AIR中使用Flex连接Sqlite数据库(2)(添加,删除,修改以及语句参数) Adobe ...

  4. Delphi 2010下使用sqlitesimpledelphi连接SQLite数据库及中文乱码问题的解决

    应女朋友的要求,要写一款销售管理的软件.用于管理服装店每天的销售记录,已及管理服装店的客户,并对客户进行生日提醒 因为之前使用C#写过一款家庭管理软件,主要是自己用,所以使用了服务器型数据库MySQL ...

  5. VS2010连接SQLite数据库

    Visual studio 2010及以上版本,连接SQLite数据库 1.在Sqlite开发站点下载SQLite的.exe安装包 Ctrl+F搜索这条语句:This is the only setu ...

  6. 一起学微软Power BI系列-使用技巧(6) 连接Sqlite数据库

    好久没有研究Power BI了,看到高飞大神弄的东西,太惭愧了.今天有个小东西,数据在Sqlite里面,想倒腾到Power BI Desktop里面折腾一下,结果发现还不直接支持.所以只好硬着头皮上去 ...

  7. VS2010上连接SQLite数据库

    VS2010连接SQLite数据库 Visual studio 2010及以上版本,连接SQLite数据库 1.在Sqlite开发站点下载SQLite的.exe安装包 Ctrl+F搜索这条语句:Thi ...

  8. C++连接sqlite数据库的坑

    新的第一次用vs2013搞 C++连接sqlite数据库,遇到了很多问题,我也不搞不懂~~~下面写点小体会 首先: 你要先配置好sqlite的环境 参考链接: https://blog.csdn.ne ...

  9. 用ASP.Net(C#)连接Oracle数据库的方法及实例

    今天看了一下asp.net连接oracle数据库的方法,得到了如下代码.这段代码打开了MyTable表,并把操作员的名字列出.字段类型是OracleString.读取的时候用的是字段编号,我不知道怎么 ...

随机推荐

  1. BZOJ 4826: [Hnoi2017]影魔 单调栈 主席树

    https://www.lydsy.com/JudgeOnline/problem.php?id=4826 年少不知空间贵,相顾mle空流泪. 和上一道主席树求的东西差不多,求两种对 1. max(a ...

  2. bzoj 2466 异或方程组

    对于每个灯,我们用一个变量表示其决策,xu=0表示不选,xu=1表示选.因为每个灯最后必须都亮,所以每个等都对应一个异或方程. 解这个异或方程组,有几种情况: 1.存在唯一解(得到的上三角系数矩阵的主 ...

  3. python开发_tkinter_自己做的猜数字小程序

    读到这篇文章[python 3.3下结合tkinter做的猜数字程序]的时候,就复制了代码,在自己机器上面跑了一下 源程序存在一个缺陷: 即当用户答对了以后,用户再点击'猜'按钮,最上面的提示标签还会 ...

  4. Big Number------HDOJ杭电1212(大数运算)

    Problem Description As we know, Big Number is always troublesome. But it's really important in our A ...

  5. 使用jquery加载部分视图02-使用$.ajax()

    本篇体验使用$.ajax()加载部分视图.与加载部分视图相关的包括: RenderPartial和RenderAction区别   使用jquery加载部分视图01-使用$.get()       □ ...

  6. 33.NET对加密和解密的支持

      散列运算 mscorlib.dll下的System.Security.Cryptography下: 抽象类HashAlgorithm     抽象类MD5         MD5CryptoSer ...

  7. xml转换成map

    import java.io.IOException;import java.io.StringReader;import java.util.ArrayList;import java.util.H ...

  8. JavaScript对于函数的调用及原理

    <js> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>< ...

  9. maven项目如何生成war文件

    配置 你的pom.xml文件,在你的overview视窗里 配置 packaging为 war 然后然后点击 pom.xml右键,run as 选择 install 或是 package如果项目没问题 ...

  10. 机器学习简史brief history of machine learning

    BRIEF HISTORY OF MACHINE LEARNING My subjective ML timeline (click for larger) Since the initial sta ...