GZDBHelper

NuGet:GZDBHelper

初始化:

 public class APIBase : ApiController
    {
        protected GZDBHelper.IDatabase db;
        public APIBase()
        {
            string sql = GZDBHelper.ConnectionStrings.BuildMSSQLConnectionString("local", "WDKB", "sa", "test");
            db = GZDBHelper.DatabaseFactory.CreateDatabase(sql, GZDBHelper.ConnectionStrings.ProviderNames.ProviderNameForMSSql, null);
        }
    }

命令参数类:

 public class SqlParameterProvider : DbParameterBase
    {

        //DbParameter GenerateParmeter(string parameterName, object value);

        //DbParameter GenerateParmeter(string parameterName, SqlDbType dbType);

        //DbParameter GenerateParmeter(string parameterName, SqlDbType dbType, int size);

        //DbParameter GenerateParmeter(string parameterName, SqlDbType dbType, int size, string sourceColumn);
        //protected abstract DbParameter GenerateParmeter(string parameterName, SqlDbType dbType, int size, string sourceColumn, ParameterDirection direction);

        //DbParameter GenerateParmeter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value);

        //DbParameter SqlParameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, bool sourceColumnNullMapping, object value, string xmlSchemaCollectionDatabase, string xmlSchemaCollectionOwningSchema, string xmlSchemaCollectionName);
        public void AddParameter(string parameterName, object value)
        {
            SqlParameter parm = new SqlParameter(parameterName, value);
            AddParameter(parm);
        }
        public void AddParameter(string parameterName, SqlDbType dbType, object value)
        {
            SqlParameter parm = new SqlParameter(parameterName, dbType);
            parm.Value = value;
            AddParameter(parm);
        }

        public void AddParameter(string parameterName, SqlDbType dbType, int size, object value)
        {
            SqlParameter parm = new SqlParameter(parameterName, dbType, size);
            parm.Value = value;
            AddParameter(parm);
        }
        public void AddParameter(string parameterName, SqlDbType dbType, int size, object value, ParameterDirection direction)
        {
            SqlParameter parm = new SqlParameter(parameterName, dbType, size);
            parm.Value = value;
            parm.Direction = direction;
            AddParameter(parm);
        }
        public void AddParameter(string parameterName, SqlDbType dbType, int size, object value, string sourceColumn)
        {
            SqlParameter parm = new SqlParameter(parameterName, dbType, size, sourceColumn);
            parm.Value = value;
            AddParameter(parm);
        }
    }

使用例子:

时间: 09-09

GZDBHelper的相关文章

GZDBHelperDemo 一

1.新建Window窗体项目GZDBHelperDemo 2.从Nuget添加GZDBHelper引用 添加完成后会出现GZDBHelper的引用 3.添加数据库链接管理类 添加类库文件:DatabaseFactoryEx.cs public class DatabaseFactoryEx { private static GZDBHelper.IDatabase db; public static GZDBHelper.IDatabase CreateDatabase() { if (db =

gzframework demo搭建

感谢框架作者,这里给出他的博客 http://www.cnblogs.com/GarsonZhang/ 背景:由于作者对代码的持续开发,导致了以前博客中的下载地址和构建方法和目前的项目不对应,这里给出自己从代码下载到demo运行的过程. 1.下载git上的代码https://github.com/GarsonZhang/GZFramework.Demo 2.此时会提示项目缺少三个项目,gzframwork.db ,gzframework.ui.core ,gzdbhelper其实这个不是项目,是