Exemplo n.º 1
0
        public DataTable GetTable(string tableName, string where = null, string orderBy = null)
        {
            var currentSql = string.Empty;
            var dt         = new DataTable(tableName);

            try
            {
                var whereCond = ConvertionHelper.GetWhere(where);
                var orderCond = ConvertionHelper.GetOrderBy(orderBy);

                var sql = currentSql = string.Format(@"SELECT * FROM {0} {1} {2}", tableName, whereCond, orderCond);
                dt = GetTable(sql);
            }
            catch (Exception ex)
            {
                SLLog.WriteError(new LogData
                {
                    Source            = ToString(),
                    FunctionName      = "GetTable Error!",
                    AdditionalMessage = $"SQL: {currentSql}",
                    Ex = ex,
                });
                if (Settings.ThrowExceptions)
                {
                    throw new Exception("GetTable Error!", ex);
                }
            }

            return(dt);
        }
Exemplo n.º 2
0
        public DataRow GetRow(string tableName, string where = null, string orderBy = null)
        {
            try
            {
                var whereCond = ConvertionHelper.GetWhere(where);
                var orderCnd  = ConvertionHelper.GetOrderBy(orderBy);

                var sql = string.Format(@"SELECT * FROM {0} {1} {2}", tableName, whereCond, orderCnd);
                return(GetRow(sql));
            }
            catch (Exception ex)
            {
                SLLog.WriteError(new LogData
                {
                    Source       = ToString(),
                    FunctionName = "GetRow Error!",
                    Ex           = ex,
                });
                if (Settings.ThrowExceptions)
                {
                    throw new Exception("GetRow Error!", ex);
                }
                return(null);
            }
        }
Exemplo n.º 3
0
        public DataTable GetTable(string tableName, string where = null, string orderBy = null)
        {
            var dt = new DataTable(tableName);

            try
            {
                var whereCond = ConvertionHelper.GetWhere(where);
                var orderCond = ConvertionHelper.GetOrderBy(orderBy);

                var sql = string.Format(@"SELECT * FROM {0} {1} {2}", tableName, whereCond, orderCond);
                dt = GetTable(sql);
            }
            catch (Exception ex)
            {
                SLLog.WriteError(new LogData
                {
                    Source       = ToString(),
                    FunctionName = "GetTable Error!",
                    Ex           = ex,
                });
            }

            return(dt);
        }