in

CodeSmith Community

Your Code. Your Way. Faster!

Yet another SQLite 3 Provider

Last post 09-22-2006 6:10 AM by Reynaldo. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-17-2006 2:07 PM

    • anelson
    • Not Ranked
    • Joined on 02-17-2006
    • Baghdad, Iraq
    • Posts 2
    • Points 40

    Yet another SQLite 3 Provider

    I've written a schema provider for SQLite 3 databases, using the .NET 2.0-only SQLite.NET library.  I've tested it with CodeSmith 3.2.  It's much like the provider based on the Finisar library posted last year, with the following differences:

    • Uses .NET 2.0 exclusively
    • Decent code coverage through a unit test suite
    • Exposes foreign key information
    I've posted the provider on my web site, at http://apocryph.org/a_sqlite_schema_provider_for_codesmith
    You can download source or binary tarballs.  If anyone has any trouble with the provider let me know. 

    Adam

    • Post Points: 35
  • 09-22-2006 6:10 AM In reply to

    • Reynaldo
    • Not Ranked
    • Joined on 08-08-2006
    • Buenos Aires, Argentina
    • Posts 1
    • Points 5

    Re: Yet another SQLite 3 Provider

    Thank you Adam, it works very well.

    I only had to make a minor change to retrive the NativeType and the DbType (with more time I'll try to get size, precision and scale).

    This is the code I changed:

    private DbType DbTypeFromType(string p)
            {
                //SQLite has only a few types:
                // INTEGER == Int64
                // NUMERIC == Decimal
                // TEXT == String
                // NONE == Object or Blob
                switch (p)
                {
                    //case "System.Int64":  //Change 9/9/06
                    case "INTEGER":  //Change 9/9/06
                        return DbType.Int64;

                    //case "System.Decimal": //Change 9/9/06
                    case "REAL":  //Change 9/9/06
                        return DbType.Decimal;

                    //case "System.String": //Change 9/9/06
                    case "TEXT":  //Change 9/9/06
                        return DbType.String;

                    default:
                        return DbType.Object;
                }                   
            }

            private string NativeTypeFromType(string p)
            {
                //SQLite has only a few types:
                // INTEGER == Int64
                // NUMERIC == Decimal
                // TEXT == String
                // NONE == Object or Blob

                return p;   //Change 9/9/06

                //switch (p)   //Change 9/9/06
                //{    //Change 9/9/06
                //    case "System.Int64":  //Change 9/9/06
                //        return "INTEGER"; //Change 9/9/06

                //    case "System.Decimal": //Change 9/9/06
                //        return "NUMERIC"; //Change 9/9/06

                //    case "System.String": //Change 9/9/06
                //        return "TEXT";  //Change 9/9/06

                //    default:   //Change 9/9/06
                //        return "NONE";  //Change 9/9/06
                //}    //Change 9/9/06
            }

    • Post Points: 5
Page 1 of 1 (2 items)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems