Exemple #1
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));
                }
            }
        }
Exemple #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));
                }
            }
        }
Exemple #3
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));
                }
            }
        }
Exemple #4
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);
            }
        }
Exemple #5
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);
            }
        }
Exemple #6
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);
            }
        }
Exemple #7
0
 /// <summary>
 /// Executes the specified query.
 /// </summary>
 /// <param name="query">The query.</param>
 protected void Execute(string query)
 {
     using (var recordset = new DisposableRecordset(company))
         recordset.DoQuery(query);
 }