Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better issue report for the Sqlite version of Massive #86

Closed
arhoads76 opened this issue Sep 19, 2011 · 1 comment
Closed

Better issue report for the Sqlite version of Massive #86

arhoads76 opened this issue Sep 19, 2011 · 1 comment

Comments

@arhoads76
Copy link

In the Sqlite version of Massive, the Schema property returns a CREATE TABLE string. It is certainly possible to parse it to get similar data as is returned from the Sql Server version of Massive. However, the following code will return column names and types like the Sql Server version of Massive:

IEnumerable<dynamic> _schema;
public IEnumerable<dynamic> Schema
{
    get
    {
        if (_schema == null) {
            var rows = new List<dynamic>();
            foreach (var row in Query("PRAGMA table_info('" + TableName + "')")) {
                rows.Add(new {
                    COLUMN_NAME = (row as IDictionary<string,object>)["name"].ToString(),
                    DATA_TYPE   = (row as IDictionary<string,object>)["type"].ToString(),
                    IS_NULLABLE = (row as IDictionary<string,object>)["notnull"].ToString() == "0" ? "NO" : "YES",
                });
            }
            _schema = rows;
        }
        return _schema;
    }
}
@robconery
Copy link
Contributor

Pull requests work a treat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants