Пример #1
0
        public static int CustomerExecuteNonQuery(string dbName, string sql, Dictionary <string, CustomerParam> paras, IDictionary hints = null, bool isWrite = true)
        {
            var baseDao = DaoCache.GetOrAdd(dbName, BaseDaoFactory.CreateBaseDao(dbName));
            var dic     = ConvertStatement(paras);

            if (dic != null && dic.Count > 0)
            {
                if (hints != null && hints.Count > 0)
                {
                    return(baseDao.ExecNonQuery(sql, dic, hints, isWrite));
                }
                return(baseDao.ExecNonQuery(sql, dic, isWrite));
            }
            if (hints != null && hints.Count > 0)
            {
                return(baseDao.ExecNonQuery(sql, null, hints, isWrite));
            }
            return(baseDao.ExecNonQuery(sql, isWrite));
        }
Пример #2
0
        public static IList <IDataReader> CustomerExecuteQuery(string dbName, string sql, Dictionary <string, CustomerParam> paras, IDictionary hints = null, bool isWrite = false)
        {
            var baseDao    = DaoCache.GetOrAdd(dbName, BaseDaoFactory.CreateBaseDao(dbName));
            var isNonQuery = false;
            var dic        = ConvertStatement(paras, out isNonQuery);

            if (dic != null && dic.Count > 0)
            {
                if (hints != null && hints.Count > 0)
                {
                    return(baseDao.SelectDataReader(sql, dic, hints, isWrite));
                }
                return(baseDao.SelectDataReader(sql, dic, isWrite));
            }
            if (hints != null && hints.Count > 0)
            {
                return(baseDao.SelectDataReader(sql, null, hints, isWrite));
            }
            return(baseDao.SelectDataReader(sql, isWrite));
        }
Пример #3
0
        public static object CustomerExecuteScalar(string dbName, string sql, Dictionary <string, CustomerParam> paras, IDictionary hints = null, bool isWrite = false)
        {
            var baseDao    = DaoCache.GetOrAdd(dbName, BaseDaoFactory.CreateBaseDao(dbName));
            var isNonQuery = false;
            var dic        = ConvertStatement(paras, out isNonQuery);

            if (dic != null && dic.Count > 0)
            {
                if (hints != null && hints.Count > 0)
                {
                    if (isNonQuery)
                    {
                        baseDao.ExecNonQuery(sql, dic, hints, isWrite);
                        var rq = dic.First(r => r.Direction.Equals(ParameterDirection.Output));
                        return(rq.Value);
                    }
                    else
                    {
                        return(baseDao.ExecScalar(sql, dic, hints, isWrite));
                    }
                }
                if (isNonQuery)
                {
                    baseDao.ExecNonQuery(sql, dic, isWrite);
                    var rq = dic.First(r => r.Direction.Equals(ParameterDirection.Output));
                    return(rq.Value);
                }
                else
                {
                    return(baseDao.ExecScalar(sql, dic, isWrite));
                }
            }
            if (hints != null && hints.Count > 0)
            {
                return(isNonQuery ? baseDao.ExecNonQuery(sql, null, hints, isWrite) : baseDao.ExecScalar(sql, null, hints, isWrite));
            }
            return(isNonQuery ? baseDao.ExecNonQuery(sql, isWrite) : baseDao.ExecScalar(sql, isWrite));
        }
Пример #4
0
        public static DataTable CustomerExecuteQueryTable(string dbName, string sql, Dictionary <string, CustomerParam> paras, IDictionary hints = null, bool isWrite = false)
        {
#if !NETSTANDARD
            var baseDao    = DaoCache.GetOrAdd(dbName, BaseDaoFactory.CreateBaseDao(dbName));
            var isNonQuery = false;
            var dic        = ConvertStatement(paras, out isNonQuery);
            if (dic != null && dic.Count > 0)
            {
                if (hints != null && hints.Count > 0)
                {
                    return(baseDao.SelectDataTable(sql, dic, hints, isWrite));
                }
                return(baseDao.SelectDataTable(sql, dic, isWrite));
            }
            if (hints != null && hints.Count > 0)
            {
                return(baseDao.SelectDataTable(sql, null, hints, isWrite));
            }
            return(baseDao.SelectDataTable(sql, isWrite));
#else
            throw new NotSupportedException("not support in dotnet core");
#endif
        }
Пример #5
0
        /// <summary>
        /// 开启事物
        /// </summary>
        /// <param name="dbName"></param>
        /// <param name="hints"></param>
        /// <returns></returns>
        public static DataConnectionTransaction CustomerBeginTransaction(string dbName, IDictionary hints = null)
        {
            var baseDao = DaoCache.GetOrAdd(dbName, BaseDaoFactory.CreateBaseDao(dbName));

            return(baseDao.BeginTransaction(hints));
        }