Ejemplo n.º 1
0
        /// <summary>
        ///   Executes the command against the connection. reads and Creates dynamic objects from the result.
        /// </summary>
        /// <param name="queryConditions">The query conditions.</param>
        /// <param name="logic">The logic.</param>
        /// <returns>IEnumerable&lt;dynamic&gt;.</returns>
        public IEnumerable <dynamic> ExecuteReaderDynamic(MKCommandParameterCollection queryConditions,
                                                          MKQueryLogicOperators logic)
        {
            //var propList = string.Join(",", MKResponseParser.GetMkPropList<TType>());
            var rows = ExecuteReader(null, queryConditions, logic);

            var result = MKResponseParser.GetDynamicList(rows);

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Excutes CommandText for read
        /// </summary>
        /// <param name="propList">
        ///     Optional:CSV of properies. limits number of Fileds that will be returned in result. it can
        ///     increase performance.
        /// </param>
        /// <param name="queryConditions">
        ///     Optional: Limits rows by condition on fields. Default logic is AND. You can change it in
        ///     Logic argument of this method
        /// </param>
        /// <param name="logic">The logic.</param>
        /// <returns>A collection of string in raw format of API result.</returns>
        public IEnumerable <string> ExecuteReader(string propList = null,
                                                  MKCommandParameterCollection queryConditions = null, MKQueryLogicOperators logic = MKQueryLogicOperators.And)
        {
            verifyConnection();

            if (!string.IsNullOrEmpty(propList))
            {
                Parameters.Add(".proplist", propList);
            }
            //*******************************************

            if (CommandText.Contains(@"/where/"))
            {
                if (queryConditions == null)
                {
                    queryConditions = new MKCommandParameterCollection();
                }
                queryConditions.AddRange(getCommandTextQueries(CommandText));
            }

            if (queryConditions != null)
            {
                foreach (var q in queryConditions)
                {
                    q.Name = "?" + q.Name;
                    Parameters.Add(q);
                }
                if (queryConditions.Count > 1)
                {
                    switch (logic)
                    {
                    case MKQueryLogicOperators.And:
                        Parameters.Add("?#", "&");
                        break;

                    case MKQueryLogicOperators.Or:
                        Parameters.Add("?#", "|");

                        break;
                    }
                }
            }

            sendCommand();
            var res = Connection.Read();

            checkResponse(res);
            return(res);
        }