• 00
  • :
  • 00
  • :
  • 00

GZDBHelper SQLite

NUGET引用

System.Data.SQLite.Core
System.Data.SQLite.Linq

 

 

 

安装System.Data.SQLite.Linq后,会生成一个app.config文件,

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  
<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></configuration>

 

 

 

安装GZDBHelper:

 

 

    public class GZDbParameterSQLite : GZDbParameter
    {
        public void AddParameter(string parameterName, System.Data.DbType dbType, object value)
        {
            SQLiteParameter p = new SQLiteParameter(parameterName, dbType);
            p.Value = value;
            this.AddParameter(p);
        }
    }

 

 StringBuilder sql = new StringBuilder();
                sql.AppendLine("INSERT INTO tb_files(type,fileName)");
                sql.AppendLine("VALUES(@type,@fileName)");

                GZDbParameterSQLite parms = new GZDbParameterSQLite();
                parms.AddParameter(new SQLiteParameter("@type", System.Data.DbType.String, type));
                parms.AddParameter(new SQLiteParameter("@fileName", System.Data.DbType.String, fileName));


                DBSQLite.Context.ExecuteNonQuery(sql.ToString(), parms);

 

详细文档参考:GZDBHelper项目简介 - GZHelper - YES快速开发平台框架,C#快速开发平台框架,WEB快速开发框架,.NET开发框架,.NET WEB开发平台框架 (yesdotnet.com)

 

posted @ 2020-11-27 11:46  Garson_Zhang  阅读(126)  评论(0编辑  收藏  举报