Skip to content

Commit 51d3511

Browse files
author
Azure Pipelines
committed
DocFX update by CI
1 parent e2eea31 commit 51d3511

10 files changed

+403
-357
lines changed

articles/FAQ.html

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -120,43 +120,43 @@ <h5>Note</h5>
120120
<p>Configure connection on creation/open (SQL Server and SQLite examples):</p>
121121
<pre><code class="lang-cs">public class MySqlServerDb : DataConnection // or DataContext
122122
{
123-
public MySqlServerDb(connectionString) : base(
124-
new DataOptions()
125-
.UseSqlServer(connectionString)
126-
.UseBeforeConnectionOpened(connection =&gt;
127-
{
128-
connection.AccessToken = &quot;..token here..&quot;;
129-
}))
130-
{
131-
}
123+
public MySqlServerDb(connectionString) : base(
124+
new DataOptions()
125+
.UseSqlServer(connectionString)
126+
.UseBeforeConnectionOpened(connection =&gt;
127+
{
128+
connection.AccessToken = &quot;..token here..&quot;;
129+
}))
130+
{
131+
}
132132
}
133133

134134
public class MySQLiteDb : DataConnection // or DataContext
135135
{
136-
public MySQLiteDb(connectionString) : base(
137-
new DataOptions()
138-
.UseSQLite(connectionString)
139-
.UseAfterConnectionOpened(
140-
connection =&gt;
141-
{
142-
using var cmd = connection.CreateCommand();
143-
cmd.CommandText = $&quot;PRAGMA KEY '{key}'&quot;;
144-
cmd.ExecuteNonQuery();
145-
},
146-
// optionally add async version to use non-blocking calls from async execution path
147-
async (connection, cancellationToken) =&gt;
148-
{
149-
using var cmd = connection.CreateCommand();
150-
cmd.CommandText = $&quot;PRAGMA KEY '{key}'&quot;;
151-
await cmd.ExecuteNonQueryAsync(cancellationToken);
152-
}))
153-
{
154-
}
136+
public MySQLiteDb(connectionString) : base(
137+
new DataOptions()
138+
.UseSQLite(connectionString)
139+
.UseAfterConnectionOpened(
140+
connection =&gt;
141+
{
142+
using var cmd = connection.CreateCommand();
143+
cmd.CommandText = $&quot;PRAGMA KEY '{key}'&quot;;
144+
cmd.ExecuteNonQuery();
145+
},
146+
// optionally add async version to use non-blocking calls from async execution path
147+
async (connection, cancellationToken) =&gt;
148+
{
149+
using var cmd = connection.CreateCommand();
150+
cmd.CommandText = $&quot;PRAGMA KEY '{key}'&quot;;
151+
await cmd.ExecuteNonQueryAsync(cancellationToken);
152+
}))
153+
{
154+
}
155155
}
156156

157157
using (var db = new MySqlServerDb())
158158
{
159-
// queries here will get pre-configured connection
159+
// queries here will get pre-configured connection
160160
}
161161
</code></pre>
162162
<h1 id="mapping">Mapping</h1>
@@ -196,12 +196,12 @@ <h2 id="how-can-i-use-sql-server-spatial-types">How can I use SQL Server spatial
196196
<h3 id="how-to-fix-it">How to fix it</h3>
197197
<p>For .NET Framework you just need to add assembly bindings redirect to your configuration file to redirect all assembly load requests to your version (make sure that <code>newVersion</code> contains proper version of assembly you have):</p>
198198
<pre><code class="lang-xml">&lt;runtime&gt;
199-
&lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
199+
&lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
200200
&lt;dependentAssembly&gt;
201-
&lt;assemblyIdentity name=&quot;Microsoft.SqlServer.Types&quot; publicKeyToken=&quot;89845dcd8080cc91&quot; culture=&quot;neutral&quot;/&gt;
202-
&lt;bindingRedirect oldVersion=&quot;0.0.0.0-14.0.0.0&quot; newVersion=&quot;14.0.0.0&quot; /&gt;
201+
&lt;assemblyIdentity name=&quot;Microsoft.SqlServer.Types&quot; publicKeyToken=&quot;89845dcd8080cc91&quot; culture=&quot;neutral&quot;/&gt;
202+
&lt;bindingRedirect oldVersion=&quot;0.0.0.0-14.0.0.0&quot; newVersion=&quot;14.0.0.0&quot; /&gt;
203203
&lt;/dependentAssembly&gt;
204-
&lt;/assemblyBinding&gt;
204+
&lt;/assemblyBinding&gt;
205205
&lt;/runtime&gt;
206206
</code></pre>
207207
<p>For .NET Core it is a bit tricky because:</p>
@@ -215,28 +215,28 @@ <h3 id="how-to-fix-it">How to fix it</h3>
215215

216216
Assembly OnAssemblyResolve(AssemblyLoadContext assemblyLoadContext, AssemblyName assemblyName)
217217
{
218-
try
219-
{
220-
// you need to unsubscribe here to avoid StackOverflowException,
221-
// as LoadFromAssemblyName will go in recursion here otherwise
222-
AssemblyLoadContext.Default.Resolving -= OnAssemblyResolve;
223-
// return resolved assembly for cases when it can be resolved
224-
return assemblyLoadContext.LoadFromAssemblyName(assemblyName);
225-
}
226-
catch
227-
{
228-
// on failue - check if it failed to load our types assembly
229-
// and explicitly return it
230-
if (assemblyName.Name == &quot;Microsoft.SqlServer.Types&quot;)
231-
return typeof(SqlGeography).Assembly;
232-
// if it failed to load some other assembly - just pass exception as-is
233-
throw;
234-
}
235-
finally
236-
{
237-
// don't forget to restore our load handler
238-
AssemblyLoadContext.Default.Resolving += OnAssemblyResolve;
239-
}
218+
try
219+
{
220+
// you need to unsubscribe here to avoid StackOverflowException,
221+
// as LoadFromAssemblyName will go in recursion here otherwise
222+
AssemblyLoadContext.Default.Resolving -= OnAssemblyResolve;
223+
// return resolved assembly for cases when it can be resolved
224+
return assemblyLoadContext.LoadFromAssemblyName(assemblyName);
225+
}
226+
catch
227+
{
228+
// on failue - check if it failed to load our types assembly
229+
// and explicitly return it
230+
if (assemblyName.Name == &quot;Microsoft.SqlServer.Types&quot;)
231+
return typeof(SqlGeography).Assembly;
232+
// if it failed to load some other assembly - just pass exception as-is
233+
throw;
234+
}
235+
finally
236+
{
237+
// don't forget to restore our load handler
238+
AssemblyLoadContext.Default.Resolving += OnAssemblyResolve;
239+
}
240240
}
241241
</code></pre>
242242

0 commit comments

Comments
 (0)