首页 > 新闻系统 > 编程天地 > 文章正文

Ent Lib 2.0 DAAB添加MySql扩展

2008-04-09 10:32:21 来源:中国自学编程网 作者:未知 点击:

        public void AddInParameter(DbCommand command, string name, MySqlDbType dbType)
        {
            AddParameter(command, name, dbType, ParameterDirection.Input, String.Empty, DataRowVersion.Default, null);
        }
        public void AddInParameter(DbCommand command, string name, MySqlDbType dbType, object value)
        {
            AddParameter(command, name, dbType, ParameterDirection.Input, String.Empty, DataRowVersion.Default, value);
        }
        public void AddInParameter(DbCommand command, string name, MySqlDbType dbType, string sourceColumn, DataRowVersion sourceVersion)
        {
            AddParameter(command, name, dbType, 0, ParameterDirection.Input, true, 0, 0, sourceColumn, sourceVersion, null);
        }
        protected DbParameter CreateParameter(string name, MySqlDbType dbType, int size, ParameterDirection direction
            , bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            MySqlParameter param = base.CreateParameter(name) as MySqlParameter;
            ConfigureParameter(param, name, dbType, size, direction, nullable, precision, scale, sourceColumn, sourceVersion, value);
            return param;
        }
        protected virtual void ConfigureParameter(MySqlParameter param, string name, MySqlDbType dbType, int size, ParameterDirection direction
            , bool nullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            param.MySqlDbType = dbType;
            param.Size = size;
            param.Value = (value == null) ? DBNull.Value : value;
            param.Direction = direction;
            param.IsNullable = nullable;
            param.SourceColumn = sourceColumn;
            param.SourceVersion = sourceVersion;
        }
    }
}
3. 测试
    没有使用NUnit,也没有使用MS的Test,直接建立一个web项目大致测试了一下。测试用的表、存储过程在DAAB MySql支持测试(Proc+DataSet更新) 5.0.27+.Net Connector 5.0.2beta中。
    在web.config文件里面加上下面的配置,注意将MySql连接字符串相关参数配置正确。
9 7 3 1 2 3 4 5 4 8 :

相关文章:

    无相关新闻
    无相关新闻

精彩推荐
焦点大图推荐
本类热门文章

论坛美图

广告联系 | 版权说明 | 意见建议 | 加入收藏 | 军网站群 [ 军软件园 - 军软件商城 - 军软件园论坛 ]

电信与信息服务业务经营许可证:京ICP证050203