/// <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)); } } }
/// <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)); } } }
/// <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)); } } }
/// <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); } }
/// <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); } }
/// <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); } }