コード例 #1
0
        public List <object> SendRequest(JSONParametrs request)
        {
            var Result = new List <object>();

            using (IDbConnection dbConnection = GetDbConnection(request))
            {
                dbConnection.Open();

                if (!request.StoredProcedure)
                {
                    Result = dbConnection.Query <object>(request.QueryString, null, null, true, request.TimeOutInSecond).ToList();
                }
                else
                {
                    var param = new DynamicParameters();
                    foreach (KeyValuePair <string, string> keyValue in request.ProcedureParam)
                    {
                        param.Add(keyValue.Key, keyValue.Value);
                    }
                    var ans = dbConnection.Query <object>(request.QueryString, param, commandType: CommandType.StoredProcedure).SingleOrDefault();
                }
            }

            return(Result);
        }
コード例 #2
0
        public List <object> GetData(JSONParametrs request)
        {
            if (request.TimeOutInSecond == 0 || request.ConnectionString == string.Empty || request.QueryString == string.Empty)
            {
                return(null);
            }

            var answer = ServiceSQL.SendRequest(request);

            return(answer);
        }
コード例 #3
0
        private IDbConnection GetDbConnection(JSONParametrs parametrs)
        {
            switch (parametrs.TypeSql)
            {
            case TypeSql.MsSql:
                return(new SqlConnection(parametrs.ConnectionString));

            case TypeSql.PostgreSql:
                return(new NpgsqlConnection(parametrs.ConnectionString));

            default:
                return(null);
            }
        }