Example #1
0
        public static XmlRecordsetReader CreateNew([NotNull] IRecordset data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var reader = new XmlRecordsetReader();

            reader.Load(data);

            return(reader);
        }
Example #2
0
        /// <summary>
        /// Selects the many.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns></returns>
        public IEnumerable <dynamic> SelectMany(string query)
        {
            using (var recordset = new DisposableRecordset(company))
            {
                recordset.DoQuery(query);

                if (recordset.RecordCount <= 0)
                {
                    yield break;
                }

                var reader = XmlRecordsetReader.CreateNew(recordset);

                while (reader.MoveNext())
                {
                    yield return(InstanceFactory.CreateDynamicObject(reader));
                }
            }
        }
Example #3
0
        /// <summary>
        /// Selects the many.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query">The query.</param>
        /// <param name="creator">The creator.</param>
        /// <returns></returns>
        public IEnumerable <T> SelectMany <T>(string query, InstanceCreator <T> creator)
        {
            using (var recordset = new DisposableRecordset(company))
            {
                recordset.DoQuery(query);

                if (recordset.RecordCount <= 0)
                {
                    yield break;
                }

                var reader = XmlRecordsetReader.CreateNew(recordset);

                while (reader.MoveNext())
                {
                    yield return(creator(reader));
                }
            }
        }
Example #4
0
        /// <summary>
        /// Selects the many.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query">The query.</param>
        /// <returns></returns>
        public IEnumerable <T> SelectMany <T>(string query) where T : class
        {
            using (var recordset = new DisposableRecordset(company))
            {
                recordset.DoQuery(query);

                if (recordset.RecordCount <= 0)
                {
                    yield break;
                }

                var reader = XmlRecordsetReader.CreateNew(recordset);

                while (reader.MoveNext())
                {
                    yield return(InstanceFactory.AutoCreateInstance <T>(reader));
                }
            }
        }
Example #5
0
        /// <summary>
        /// Selects a single record from the database.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns></returns>
        public dynamic SelectOne(string query)
        {
            using (var recordset = new DisposableRecordset(company))
            {
                recordset.DoQuery(query);
                if (recordset.RecordCount <= 0)
                {
                    return(null);
                }

                var reader = XmlRecordsetReader.CreateNew(recordset);

                if (reader.MoveNext())
                {
                    return(InstanceFactory.CreateDynamicObject(reader));
                }

                return(null);
            }
        }
Example #6
0
        /// <summary>
        /// Selects a single record from the database.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query">The query.</param>
        /// <returns></returns>
        public T SelectOne <T>(string query) where T : class
        {
            using (var recordset = new DisposableRecordset(company))
            {
                recordset.DoQuery(query);

                if (recordset.RecordCount <= 0)
                {
                    return(null);
                }

                var reader = XmlRecordsetReader.CreateNew(recordset);

                if (reader.MoveNext())
                {
                    return(InstanceFactory.AutoCreateInstance <T>(reader));
                }

                return(null);
            }
        }
Example #7
0
        /// <summary>
        /// Selects a single record from the database.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query">The query.</param>
        /// <param name="creator">The creator.</param>
        /// <param name="default">The default.</param>
        /// <returns></returns>
        public T SelectOne <T>(string query, InstanceCreator <T> creator, T @default) where T : class
        {
            using (var recordset = new DisposableRecordset(company))
            {
                recordset.DoQuery(query);

                if (recordset.RecordCount <= 0)
                {
                    return(@default);
                }

                var reader = XmlRecordsetReader.CreateNew(recordset);

                if (reader.MoveNext())
                {
                    return(creator(reader));
                }

                return(@default);
            }
        }