Click here to Skip to main content
15,896,153 members
Articles / Programming Languages / SQL

NetBase - A Minimal .NET Database with a Small SQL Parser, Part 1

Rate me:
Please Sign up or sign in to vote.
4.21/5 (7 votes)
3 Nov 2009LGPL36 min read 44K   1.3K   36  
This is a small database system that reads and writes to DBF-like files, with a SQL front-end.
/*
NetBase .NET database
Copyright (C) 2009  buttonpusher

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using NetBase.Sql;

namespace NetBase.Api
{
    public class DbfCommand : DbCommand
    {
        internal Sql.IQuery UnderlyingQuery { get; set; }

        public DbfCommand(DbfConnection con)
        {
            this.Connection = con;
        }

        public override void Cancel()
        {
            throw new NotImplementedException();
        }

        public override string CommandText {get;set;}
        
        public override int CommandTimeout
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override System.Data.CommandType CommandType
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        protected override DbParameter CreateDbParameter()
        {
            throw new NotImplementedException();
        }

        protected override DbConnection DbConnection {get;set;}
        
        protected override DbParameterCollection DbParameterCollection
        {
            get { throw new NotImplementedException(); }
        }

        protected override DbTransaction DbTransaction
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override bool DesignTimeVisible
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        protected override DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior behavior)
        {
            this.Prepare();

            Storage.ITable tbl = ((DbfConnection)this.DbConnection)
                .UnderlyingDatabase.Execute(this.UnderlyingQuery.Runnable);

            if (this.UnderlyingQuery.GetType() == typeof(SelectQuery))
            {
                return new DbfDataReader(tbl);
            }
            return null;
           
        }

        public override int ExecuteNonQuery()
        {
            throw new NotImplementedException();
        }

        public override object ExecuteScalar()
        {
            throw new NotImplementedException();
        }

        public override void Prepare()
        {
            QueryBuilder qb = new QueryBuilder();
            this.UnderlyingQuery = qb.Parse(this.CommandText);
        }

        public override System.Data.UpdateRowSource UpdatedRowSource
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
    }
}

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 GNU Lesser General Public License (LGPLv3)


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions