Пример #1
0
 /// <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
                ));
 }
Пример #2
0
        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;
        }
Пример #3
0
 /// <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));
 }
Пример #4
0
        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);
            }
             }
        }
Пример #5
0
 /// <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));
 }
Пример #6
0
 /// <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);
 }
Пример #7
0
        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;
        }
Пример #8
0
 /// <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);
 }
Пример #9
0
        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);
        }
Пример #10
0
 /// <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);
 }
Пример #11
0
 /// <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);
 }
Пример #12
0
 /// <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);
 }
Пример #13
0
 /// <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);
 }
Пример #14
0
 /// <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
      );
 }
Пример #15
0
 /// <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));
 }
Пример #16
0
 /// <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);
 }
Пример #17
0
 /// <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));
 }
Пример #18
0
 /// <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);
 }