/// <summary> /// Initializes a new instance of the <see cref="DataReaderReader"/> /// </summary> /// <param name="mapper"> /// A <see cref="IDataReaderMapper{T}"/> that should be used to map /// the data containined into the <paramref name="reader"/> to a /// object or a collection of objects of the type <typeparamref name="T"/>. /// </param> /// <param name="reader"> /// A <see cref="IDataReader"/> to fetch the data. /// </param> /// <param name="disposables"> /// A collection of <see cref="IDisposable"/> objects related with the /// given <paramref name="reader"/> that needs to be disposed as the same /// time as the <see cref="QueryMapper{T}"/> object. /// </param> public QueryMapper(IDataReaderMapper <T> mapper, IDataReader reader, IEnumerable <IDisposable> disposables) { mapper_ = mapper; reader_ = reader; disposables_ = disposables.ToArray(); }
/// <summary> /// Resolve the given <paramref name="criteria"/> into a /// <see cref="IDataReaderMapper{T}"/> object. /// </summary> public static IDataReaderMapper <T> Resolve <T>(this ICriteria criteria, string prefix) { object obj; string hash = prefix + ":" + criteria.Fields.Join(":"); if (mappers_.TryGetValue(hash, out obj)) { return((IDataReaderMapper <T>)obj); } var builder = new DataReaderMapperBuilder <T>(); foreach (var field in criteria.Fields) { string map = criteria.GetFieldMap(field); builder.Map(field, map); } IDataReaderMapper <T> mapper = builder.Build(); mappers_.Add(hash, mapper); return(mapper); }
/// <summary> /// Initializes a new instance of the <see cref="QueryMapper{T}"/> /// </summary> /// <param name="mapper"> /// A <see cref="IDataReaderMapper{T}"/> that should be used to map /// the data containined into the <paramref name="reader"/> to a /// object or a collection of objects of the type <typeparamref name="T"/>. /// </param> /// <param name="reader"> /// A <see cref="IDataReader"/> to fetch the data. /// </param> public QueryMapper(IDataReaderMapper <T> mapper, IDataReader reader) : this(mapper, reader, Enumerable.Empty <IDisposable>()) { }
/// <summary> /// Initializes a new instance of the <see cref="NextHiQuery"/> /// using the given <param ref="sql_connection_provider" /> /// </summary> /// <param name="sql_connection_provider"> /// A <see cref="SqlConnectionProvider"/> object that can be used to /// create connections to the data provider. /// </param> public NextHiQuery(SqlConnectionProvider sql_connection_provider) { sql_connection_provider_ = sql_connection_provider; logger_ = MustLogger.ForCurrentProcess; mapper_ = CreateMapper(); }
/// <summary> /// Initializes a new instance of the <see cref="IdleTimeAtTimeQuery"/> /// using the given <param ref="sql_connection_provider" /> /// </summary> /// <param name="sql_connection_provider"> /// A <see cref="SqlCeConnectionProvider"/> object that can be used to /// create connections to the data provider. /// </param> public IdleTimeAtTimeQuery(SqlCeConnectionProvider sql_connection_provider) { sql_connection_provider_ = sql_connection_provider; logger_ = AionLogger.ForCurrentProcess; mapper_ = Mappers.IdleTimeInfo(); }