Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes it is possible and support for this is already built into the <code>OrmLiteConnectionFactory</code>, see the <a href="https://github.com/ServiceStack/ServiceStack.OrmLite#sharding-1000-robots-into-10-sqlite-db-shards---referencing-each-in-a-master-sqlserver-rdbms">Master SQLServer + Sqlite shard example on OrmLite's project home page</a>. </p> <p>Basically you would register your <strong>default</strong> (or master) connection first with:</p> <pre><code>var dbFactory = new OrmLiteConnectionFactory( "Data Source=host;Initial Catalog=RobotsMaster;Integrated Security=SSPI", SqlServerDialect.Provider); </code></pre> <p>Then you would register a <strong>named connection</strong> for every other connection you wish to support, e.g:</p> <pre><code>dbFactory.RegisterConnection("shard-1", "~/App_Data/{0}.sqlite".Fmt(shardId).MapAbsolutePath(), SqliteDialect.Provider); </code></pre> <p>Once that's configured, opening a connection without specifying a name will open a connection to the default database, e.g:</p> <pre><code>using (IDbConnection db = dbFactory.OpenDbConnection()) { ... } //Default DB </code></pre> <p>Whilst you can specify a name to open up a named connection to a db with a different provider, e.g:</p> <pre><code>using (var dbShard = dbFactory.OpenDbConnection("shard-1")) { ... } //Named DB </code></pre> <h3>Manually use different Dialect Providers</h3> <p>The differences between the SQL Provider implementations between different RDBMS's are contained within each dialect provider. So if you want to use OrmLite's convenience extension methods against an specific ADO.NET provider implementation you just need to assign the ThreadStatic DialectProvider you wish to use, e.g:</p> <pre><code>OrmLiteConfig.DialectProvider = SqlServerDialect.Provider; var dbConn = new SqlConnection(SqlServerConnString); dbConn.Select&lt;Table&gt;(); //All db access now uses the above dialect provider </code></pre> <p>This is essentially all what <code>RegisterConnection</code> in OrmLiteConnectionFactory automatically does behind the scenes for you. </p> <p>For reference here are all the dialect providers for OrmLite up to this point:</p> <ul> <li>SqlServerDialect.Provider</li> <li>SqliteDialect.Provider (different 32/64 and Mono impls available)</li> <li>MySqlDialect.Provider</li> <li>PostgreSqlDialect.Provider</li> <li>OracleDialect.Provider</li> <li>FirebirdDialect.Provider</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload