示例#1
0
        public SoodaDataSource OpenDataSource(Sooda.Schema.DataSourceInfo dataSourceInfo, IDbConnection connection)
        {
            foreach (SoodaDataSource dataSource in _dataSources)
            {
                if (dataSource.Name == dataSourceInfo.Name)
                {
                    return(dataSource);
                }
            }

            SoodaDataSource ds = (SoodaDataSource)dataSourceInfo.CreateDataSource();

            _dataSources.Add(ds);
            ds.Statistics     = this.Statistics;
            ds.IsolationLevel = IsolationLevel;
            if (connection != null)
            {
                ds.Connection = connection;
            }
            else
            {
                ds.Open();
            }
            if (_savingObjects)
            {
                ds.BeginSaveChanges();
            }
            return(ds);
        }
示例#2
0
 public SqlDataSource(Sooda.Schema.DataSourceInfo dataSourceInfo) : this(dataSourceInfo.Name)
 {
 }
 protected SoodaDataSource(Sooda.Schema.DataSourceInfo dataSourceInfo)
 {
     _name = dataSourceInfo.Name;
 }
        public override int Run(string[] args)
        {
            SchemaImporter importer = null;

            switch (DatabaseType)
            {
                case "mssql":
                case "sqlserver":
                    importer = new MSSqlSchemaImporter();
                    break;
            }

            SchemaInfo schemaInfo = importer.GetSchemaFromDatabase(this);
            AutoDetectRelations(schemaInfo);
            schemaInfo.Resolve();
            RemoveReferencePrimaryKeys(schemaInfo);
            AutoDetectCollections(schemaInfo);

            DataSourceInfo dsi = new DataSourceInfo();
            dsi.Name = "default";
            dsi.DataSourceType = "Sooda.Sql.SqlDataSource";
            schemaInfo.DataSources.Add(dsi);
            foreach (ClassInfo ci in schemaInfo.Classes)
            {
                int pkCount = 0;
                foreach (FieldInfo fi in ci.LocalTables[0].Fields)
                {
                    if (fi.IsPrimaryKey)
                    {
                        pkCount++;
                    }
                }
                if (pkCount == 0)
                    Console.WriteLine("WARNING: Table {0} doesn't have a primary key.", ci.Name);
            }
            XmlSerializer ser = new XmlSerializer(typeof(SchemaInfo));
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            ns.Add("", SchemaInfo.XmlNamespace);

            using (FileStream fs = File.Create(OutputFile))
            {
                ser.Serialize(fs, schemaInfo, ns);
            }

            return 0;
        }
示例#5
0
 public SoodaDataSource OpenDataSource(Sooda.Schema.DataSourceInfo dataSourceInfo)
 {
     return(OpenDataSource(dataSourceInfo, null));
 }