Click here to Skip to main content
15,885,309 members
Articles / Database Development / SQL Server

DACBuilder – Data Access objects generation tool based on XML and XSL templates transformation

Rate me:
Please Sign up or sign in to vote.
5.00/5 (13 votes)
31 Mar 2006CPOL23 min read 75.9K   1.9K   68  
The DACBuilder application provides auto-generation features from multiple database systems in multiple programming languages.
//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.1.4322.573
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

namespace DACBuilder.Templates {
    using System;
    using System.Data;
    using System.Xml;
    using System.Runtime.Serialization;
    
    
    [Serializable()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Diagnostics.DebuggerStepThrough()]
    [System.ComponentModel.ToolboxItem(true)]
    public class dataset_template : DataSet {
        
        private ReportDataTable tableReport;
        
        public dataset_template() {
            this.InitClass();
            System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
            this.Tables.CollectionChanged += schemaChangedHandler;
            this.Relations.CollectionChanged += schemaChangedHandler;
        }
        
        protected dataset_template(SerializationInfo info, StreamingContext context) {
            string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
            if ((strSchema != null)) {
                DataSet ds = new DataSet();
                ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));
                if ((ds.Tables["Report"] != null)) {
                    this.Tables.Add(new ReportDataTable(ds.Tables["Report"]));
                }
                this.DataSetName = ds.DataSetName;
                this.Prefix = ds.Prefix;
                this.Namespace = ds.Namespace;
                this.Locale = ds.Locale;
                this.CaseSensitive = ds.CaseSensitive;
                this.EnforceConstraints = ds.EnforceConstraints;
                this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
                this.InitVars();
            }
            else {
                this.InitClass();
            }
            this.GetSerializationData(info, context);
            System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
            this.Tables.CollectionChanged += schemaChangedHandler;
            this.Relations.CollectionChanged += schemaChangedHandler;
        }
        
        [System.ComponentModel.Browsable(false)]
        [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
        public ReportDataTable Report {
            get {
                return this.tableReport;
            }
        }
        
        public override DataSet Clone() {
            dataset_template cln = ((dataset_template)(base.Clone()));
            cln.InitVars();
            return cln;
        }
        
        protected override bool ShouldSerializeTables() {
            return false;
        }
        
        protected override bool ShouldSerializeRelations() {
            return false;
        }
        
        protected override void ReadXmlSerializable(XmlReader reader) {
            this.Reset();
            DataSet ds = new DataSet();
            ds.ReadXml(reader);
            if ((ds.Tables["Report"] != null)) {
                this.Tables.Add(new ReportDataTable(ds.Tables["Report"]));
            }
            this.DataSetName = ds.DataSetName;
            this.Prefix = ds.Prefix;
            this.Namespace = ds.Namespace;
            this.Locale = ds.Locale;
            this.CaseSensitive = ds.CaseSensitive;
            this.EnforceConstraints = ds.EnforceConstraints;
            this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
            this.InitVars();
        }
        
        protected override System.Xml.Schema.XmlSchema GetSchemaSerializable() {
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            this.WriteXmlSchema(new XmlTextWriter(stream, null));
            stream.Position = 0;
            return System.Xml.Schema.XmlSchema.Read(new XmlTextReader(stream), null);
        }
        
        internal void InitVars() {
            this.tableReport = ((ReportDataTable)(this.Tables["Report"]));
            if ((this.tableReport != null)) {
                this.tableReport.InitVars();
            }
        }
        
        private void InitClass() {
            this.DataSetName = "dataset_template";
            this.Prefix = "";
            this.Namespace = "http://tempuri.org/dataset_template.xsd";
            this.Locale = new System.Globalization.CultureInfo("en-US");
            this.CaseSensitive = false;
            this.EnforceConstraints = true;
            this.tableReport = new ReportDataTable();
            this.Tables.Add(this.tableReport);
        }
        
        private bool ShouldSerializeReport() {
            return false;
        }
        
        private void SchemaChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) {
            if ((e.Action == System.ComponentModel.CollectionChangeAction.Remove)) {
                this.InitVars();
            }
        }
        
        public delegate void ReportRowChangeEventHandler(object sender, ReportRowChangeEvent e);
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ReportDataTable : DataTable, System.Collections.IEnumerable {
            
            private DataColumn columnID_Report;
            
            private DataColumn columnTitoloReport;
            
            private DataColumn columnPercorso;
            
            private DataColumn columnPagina;
            
            private DataColumn columnTipo;
            
            private DataColumn columnServer;
            
            private DataColumn columnDB;
            
            private DataColumn columnLogin;
            
            private DataColumn columnPwd;
            
            private DataColumn columnAlbero;
            
            internal ReportDataTable() : 
                    base("Report") {
                this.InitClass();
            }
            
            internal ReportDataTable(DataTable table) : 
                    base(table.TableName) {
                if ((table.CaseSensitive != table.DataSet.CaseSensitive)) {
                    this.CaseSensitive = table.CaseSensitive;
                }
                if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) {
                    this.Locale = table.Locale;
                }
                if ((table.Namespace != table.DataSet.Namespace)) {
                    this.Namespace = table.Namespace;
                }
                this.Prefix = table.Prefix;
                this.MinimumCapacity = table.MinimumCapacity;
                this.DisplayExpression = table.DisplayExpression;
            }
            
            [System.ComponentModel.Browsable(false)]
            public int Count {
                get {
                    return this.Rows.Count;
                }
            }
            
            internal DataColumn ID_ReportColumn {
                get {
                    return this.columnID_Report;
                }
            }
            
            internal DataColumn TitoloReportColumn {
                get {
                    return this.columnTitoloReport;
                }
            }
            
            internal DataColumn PercorsoColumn {
                get {
                    return this.columnPercorso;
                }
            }
            
            internal DataColumn PaginaColumn {
                get {
                    return this.columnPagina;
                }
            }
            
            internal DataColumn TipoColumn {
                get {
                    return this.columnTipo;
                }
            }
            
            internal DataColumn ServerColumn {
                get {
                    return this.columnServer;
                }
            }
            
            internal DataColumn DBColumn {
                get {
                    return this.columnDB;
                }
            }
            
            internal DataColumn LoginColumn {
                get {
                    return this.columnLogin;
                }
            }
            
            internal DataColumn PwdColumn {
                get {
                    return this.columnPwd;
                }
            }
            
            internal DataColumn AlberoColumn {
                get {
                    return this.columnAlbero;
                }
            }
            
            public ReportRow this[int index] {
                get {
                    return ((ReportRow)(this.Rows[index]));
                }
            }
            
            public event ReportRowChangeEventHandler ReportRowChanged;
            
            public event ReportRowChangeEventHandler ReportRowChanging;
            
            public event ReportRowChangeEventHandler ReportRowDeleted;
            
            public event ReportRowChangeEventHandler ReportRowDeleting;
            
            public void AddReportRow(ReportRow row) {
                this.Rows.Add(row);
            }
            
            public ReportRow AddReportRow(string TitoloReport, string Percorso, string Pagina, string Tipo, string Server, string DB, string Login, string Pwd, bool Albero) {
                ReportRow rowReportRow = ((ReportRow)(this.NewRow()));
                rowReportRow.ItemArray = new object[] {
                        null,
                        TitoloReport,
                        Percorso,
                        Pagina,
                        Tipo,
                        Server,
                        DB,
                        Login,
                        Pwd,
                        Albero};
                this.Rows.Add(rowReportRow);
                return rowReportRow;
            }
            
            public ReportRow FindByID_Report(int ID_Report) {
                return ((ReportRow)(this.Rows.Find(new object[] {
                            ID_Report})));
            }
            
            public System.Collections.IEnumerator GetEnumerator() {
                return this.Rows.GetEnumerator();
            }
            
            public override DataTable Clone() {
                ReportDataTable cln = ((ReportDataTable)(base.Clone()));
                cln.InitVars();
                return cln;
            }
            
            protected override DataTable CreateInstance() {
                return new ReportDataTable();
            }
            
            internal void InitVars() {
                this.columnID_Report = this.Columns["ID_Report"];
                this.columnTitoloReport = this.Columns["TitoloReport"];
                this.columnPercorso = this.Columns["Percorso"];
                this.columnPagina = this.Columns["Pagina"];
                this.columnTipo = this.Columns["Tipo"];
                this.columnServer = this.Columns["Server"];
                this.columnDB = this.Columns["DB"];
                this.columnLogin = this.Columns["Login"];
                this.columnPwd = this.Columns["Pwd"];
                this.columnAlbero = this.Columns["Albero"];
            }
            
            private void InitClass() {
                this.columnID_Report = new DataColumn("ID_Report", typeof(int), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnID_Report);
                this.columnTitoloReport = new DataColumn("TitoloReport", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnTitoloReport);
                this.columnPercorso = new DataColumn("Percorso", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnPercorso);
                this.columnPagina = new DataColumn("Pagina", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnPagina);
                this.columnTipo = new DataColumn("Tipo", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnTipo);
                this.columnServer = new DataColumn("Server", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnServer);
                this.columnDB = new DataColumn("DB", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnDB);
                this.columnLogin = new DataColumn("Login", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnLogin);
                this.columnPwd = new DataColumn("Pwd", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnPwd);
                this.columnAlbero = new DataColumn("Albero", typeof(bool), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnAlbero);
                this.Constraints.Add(new UniqueConstraint("dataset_templateKey1", new DataColumn[] {
                                this.columnID_Report}, true));
                this.columnID_Report.AutoIncrement = true;
                this.columnID_Report.AllowDBNull = false;
                this.columnID_Report.ReadOnly = true;
                this.columnID_Report.Unique = true;
                this.columnTitoloReport.AllowDBNull = false;
                this.columnPercorso.AllowDBNull = false;
                this.columnPagina.AllowDBNull = false;
                this.columnTipo.AllowDBNull = false;
                this.columnAlbero.AllowDBNull = false;
            }
            
            public ReportRow NewReportRow() {
                return ((ReportRow)(this.NewRow()));
            }
            
            protected override DataRow NewRowFromBuilder(DataRowBuilder builder) {
                return new ReportRow(builder);
            }
            
            protected override System.Type GetRowType() {
                return typeof(ReportRow);
            }
            
            protected override void OnRowChanged(DataRowChangeEventArgs e) {
                base.OnRowChanged(e);
                if ((this.ReportRowChanged != null)) {
                    this.ReportRowChanged(this, new ReportRowChangeEvent(((ReportRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowChanging(DataRowChangeEventArgs e) {
                base.OnRowChanging(e);
                if ((this.ReportRowChanging != null)) {
                    this.ReportRowChanging(this, new ReportRowChangeEvent(((ReportRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleted(DataRowChangeEventArgs e) {
                base.OnRowDeleted(e);
                if ((this.ReportRowDeleted != null)) {
                    this.ReportRowDeleted(this, new ReportRowChangeEvent(((ReportRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleting(DataRowChangeEventArgs e) {
                base.OnRowDeleting(e);
                if ((this.ReportRowDeleting != null)) {
                    this.ReportRowDeleting(this, new ReportRowChangeEvent(((ReportRow)(e.Row)), e.Action));
                }
            }
            
            public void RemoveReportRow(ReportRow row) {
                this.Rows.Remove(row);
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ReportRow : DataRow {
            
            private ReportDataTable tableReport;
            
            internal ReportRow(DataRowBuilder rb) : 
                    base(rb) {
                this.tableReport = ((ReportDataTable)(this.Table));
            }
            
            public int ID_Report {
                get {
                    return ((int)(this[this.tableReport.ID_ReportColumn]));
                }
                set {
                    this[this.tableReport.ID_ReportColumn] = value;
                }
            }
            
            public string TitoloReport {
                get {
                    return ((string)(this[this.tableReport.TitoloReportColumn]));
                }
                set {
                    this[this.tableReport.TitoloReportColumn] = value;
                }
            }
            
            public string Percorso {
                get {
                    return ((string)(this[this.tableReport.PercorsoColumn]));
                }
                set {
                    this[this.tableReport.PercorsoColumn] = value;
                }
            }
            
            public string Pagina {
                get {
                    return ((string)(this[this.tableReport.PaginaColumn]));
                }
                set {
                    this[this.tableReport.PaginaColumn] = value;
                }
            }
            
            public string Tipo {
                get {
                    return ((string)(this[this.tableReport.TipoColumn]));
                }
                set {
                    this[this.tableReport.TipoColumn] = value;
                }
            }
            
            public string Server {
                get {
                    try {
                        return ((string)(this[this.tableReport.ServerColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                    }
                }
                set {
                    this[this.tableReport.ServerColumn] = value;
                }
            }
            
            public string DB {
                get {
                    try {
                        return ((string)(this[this.tableReport.DBColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                    }
                }
                set {
                    this[this.tableReport.DBColumn] = value;
                }
            }
            
            public string Login {
                get {
                    try {
                        return ((string)(this[this.tableReport.LoginColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                    }
                }
                set {
                    this[this.tableReport.LoginColumn] = value;
                }
            }
            
            public string Pwd {
                get {
                    try {
                        return ((string)(this[this.tableReport.PwdColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                    }
                }
                set {
                    this[this.tableReport.PwdColumn] = value;
                }
            }
            
            public bool Albero {
                get {
                    return ((bool)(this[this.tableReport.AlberoColumn]));
                }
                set {
                    this[this.tableReport.AlberoColumn] = value;
                }
            }
            
            public bool IsServerNull() {
                return this.IsNull(this.tableReport.ServerColumn);
            }
            
            public void SetServerNull() {
                this[this.tableReport.ServerColumn] = System.Convert.DBNull;
            }
            
            public bool IsDBNull() {
                return this.IsNull(this.tableReport.DBColumn);
            }
            
            public void SetDBNull() {
                this[this.tableReport.DBColumn] = System.Convert.DBNull;
            }
            
            public bool IsLoginNull() {
                return this.IsNull(this.tableReport.LoginColumn);
            }
            
            public void SetLoginNull() {
                this[this.tableReport.LoginColumn] = System.Convert.DBNull;
            }
            
            public bool IsPwdNull() {
                return this.IsNull(this.tableReport.PwdColumn);
            }
            
            public void SetPwdNull() {
                this[this.tableReport.PwdColumn] = System.Convert.DBNull;
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ReportRowChangeEvent : EventArgs {
            
            private ReportRow eventRow;
            
            private DataRowAction eventAction;
            
            public ReportRowChangeEvent(ReportRow row, DataRowAction action) {
                this.eventRow = row;
                this.eventAction = action;
            }
            
            public ReportRow Row {
                get {
                    return this.eventRow;
                }
            }
            
            public DataRowAction Action {
                get {
                    return this.eventAction;
                }
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer Telstra Internet
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions