/// <summary> /// Returns an <see cref="XmlReader"/> object that provides an XML view of the set's data. /// </summary> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public XmlReader AsXml(XmlMappingSettings settings) { return(new XmlMappingReader( this.Connection.Map <IDataRecord>(GetDefiningQuery(clone: true), r => r, this.Log).GetEnumerator(), settings, (XmlReaderSettings)null )); }
public XmlMappingReader( IEnumerator <IDataRecord> enumerator, XmlMappingSettings mappingSettings, XmlReaderSettings readerSettings) { if (enumerator == null) { throw new ArgumentNullException("enumerator"); } mappingSettings = mappingSettings ?? XmlMappingSettings.Defaults; this.enumerator = enumerator; this._Settings = readerSettings ?? closeInputSettings; this.xsiNil = mappingSettings.NullHandling == XmlNullHandling.IncludeNilAttribute; this.xsiType = mappingSettings.TypeAnnotation == XmlTypeAnnotation.XmlSchema; this.tableName = mappingSettings.CollectionName; this.rowName = mappingSettings.ItemName; }
/// <summary> /// Maps the results of the <paramref name="query"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="query">The query.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public XmlReader MapXml(SqlBuilder query, XmlMappingSettings settings) { return(CreateCommand(query).MapXml(settings, this.Log)); }
public void Xml() { var query = SQL .SELECT("p.ProductID, p.ProductName") ._("c.CategoryID AS Category$CategoryID") ._("c.CategoryName AS Category$CategoryName") ._("p.UnitPrice") .FROM("Products p") .LEFT_JOIN("Categories c ON p.CategoryID = c.CategoryID") .WHERE("ProductID < {0}", 3); var settings = new XmlMappingSettings { CollectionName = new XmlQualifiedName("Products", "http://example.com/ns/Store"), ItemName = "Product", NullHandling = XmlNullHandling.IncludeNilAttribute, TypeAnnotation = XmlTypeAnnotation.XmlSchema }; using (XmlReader reader = conn.MapXml(query, settings, log)) { using (XmlWriter writer = XmlWriter.Create(log, new XmlWriterSettings { Indent = true })) { while (!reader.EOF) writer.WriteNode(reader, defattr: true); } } }
/// <summary> /// Maps the results of the <paramref name="query"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="connection">The connection.</param> /// <param name="query">The query.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <param name="logger">A <see cref="TextWriter"/> used to log when the command is executed.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public static XmlReader MapXml(this DbConnection connection, SqlBuilder query, XmlMappingSettings settings, TextWriter logger) { return(connection.CreateCommand(query).MapXml(settings, logger)); }
/// <summary> /// Maps the results of the <paramref name="query"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="connection">The connection.</param> /// <param name="query">The query.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public static XmlReader MapXml(this DbConnection connection, SqlBuilder query, XmlMappingSettings settings) { return connection.CreateCommand(query).MapXml(settings); }
public XmlMappingReader( IEnumerator<IDataRecord> enumerator, XmlMappingSettings mappingSettings, XmlReaderSettings readerSettings) { if (enumerator == null) throw new ArgumentNullException("enumerator"); mappingSettings = mappingSettings ?? XmlMappingSettings.Defaults; this.enumerator = enumerator; this._Settings = readerSettings ?? closeInputSettings; this.xsiNil = mappingSettings.NullHandling == XmlNullHandling.IncludeNilAttribute; this.xsiType = mappingSettings.TypeAnnotation == XmlTypeAnnotation.XmlSchema; this.tableName = mappingSettings.CollectionName; this.rowName = mappingSettings.ItemName; }
/// <summary> /// Maps the results of the <paramref name="query"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="connection">The connection.</param> /// <param name="query">The query.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <param name="logger">A <see cref="TextWriter"/> used to log when the command is executed.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public static XmlReader MapXml(this DbConnection connection, SqlBuilder query, XmlMappingSettings settings, TextWriter logger) { return MapXml(q => connection.CreateCommand(q), query, settings, logger); }
internal static XmlReader MapXml(Func<SqlBuilder, IDbCommand> queryToCommand, SqlBuilder query, XmlMappingSettings settings, TextWriter logger) { if (query.HasIgnoredColumns) { if (settings == null) { settings = new XmlMappingSettings(); } foreach (int item in query.IgnoredColumns) { settings.IgnoredColumns.Add(item); } } return MapXml(queryToCommand(query), settings, logger); }
/// <summary> /// Maps the results of the <paramref name="command"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="command">The query command.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <param name="logger">A <see cref="TextWriter"/> used to log when the command is executed.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public static XmlReader MapXml(this IDbCommand command, XmlMappingSettings settings, TextWriter logger) { return new XmlMappingReader(command.Map(r => r, logger).GetEnumerator(), settings, (XmlReaderSettings)null); }
/// <summary> /// Maps the results of the <paramref name="query"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="connection">The connection.</param> /// <param name="query">The query.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public static XmlReader MapXml(this DbConnection connection, SqlBuilder query, XmlMappingSettings settings) { return MapXml(connection, query, settings, (TextWriter)null); }
/// <summary> /// Maps the results of the <paramref name="command"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="command">The query command.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public static XmlReader MapXml(this IDbCommand command, XmlMappingSettings settings) { return MapXml(command, settings, (TextWriter)null); }
/// <summary> /// Maps the results of the <paramref name="query"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="query">The query.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public XmlReader MapXml(SqlBuilder query, XmlMappingSettings settings) { return Extensions.MapXml(q => CreateCommand(q), query, settings, this.Log); }
/// <summary> /// Returns an <see cref="XmlReader"/> object that provides an XML view of the set's data. /// </summary> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public XmlReader AsXml(XmlMappingSettings settings) { return new XmlMappingReader( this.Connection.Map<IDataRecord>(GetDefiningQuery(clone: true), r => r, this.Log).GetEnumerator(), settings, (XmlReaderSettings)null ); }
/// <summary> /// Maps the results of the <paramref name="command"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="command">The query command.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public static XmlReader MapXml(this IDbCommand command, XmlMappingSettings settings) { return(MapXml(command, settings, (TextWriter)null)); }
/// <summary> /// Returns an <see cref="XmlReader"/> object that provides an XML view of the set's data. /// </summary> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public XmlReader AsXml(XmlMappingSettings settings) { return Extensions.MapXml(q => CreateCommand(q), GetDefiningQuery(), settings, this.Log); }
/// <summary> /// Maps the results of the <paramref name="command"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="command">The query command.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <param name="logger">A <see cref="TextWriter"/> used to log when the command is executed.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public static XmlReader MapXml(this IDbCommand command, XmlMappingSettings settings, TextWriter logger) { return(new XmlMappingReader(command.Map(r => r, logger).GetEnumerator(), settings, (XmlReaderSettings)null)); }
/// <summary> /// Maps the results of the <paramref name="query"/> to XML. /// The query is deferred-executed. /// </summary> /// <param name="query">The query.</param> /// <param name="settings">An <see cref="XmlMappingSettings"/> object that customizes the mapping.</param> /// <returns>An <see cref="XmlReader"/> object.</returns> public XmlReader MapXml(SqlBuilder query, XmlMappingSettings settings) { return CreateCommand(query).MapXml(settings, this.Log); }