Skip to content

Commit e9f5690

Browse files
sdanylivMaceWindu
andauthored
Unified indent size code samples. (#53)
* Unified indent size. * Formatting. * Update source/articles/how-to/teach-linq2db-convert-custom-net-code-to-sql.md * Update source/articles/how-to/using-mapvalue-attribute-to-control-mapping.md * Update source/articles/how-to/teach-linq2db-convert-custom-net-code-to-sql.md * add articles to menu, additional formatting fixes --------- Co-authored-by: MaceWindu <[email protected]>
1 parent dc29ec0 commit e9f5690

File tree

6 files changed

+355
-364
lines changed

6 files changed

+355
-364
lines changed

source/articles/FAQ.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -30,43 +30,43 @@ Configure connection on creation/open (SQL Server and SQLite examples):
3030
```cs
3131
public class MySqlServerDb : DataConnection // or DataContext
3232
{
33-
public MySqlServerDb(connectionString) : base(
34-
new DataOptions()
35-
.UseSqlServer(connectionString)
36-
.UseBeforeConnectionOpened(connection =>
37-
{
38-
connection.AccessToken = "..token here..";
39-
}))
40-
{
41-
}
33+
public MySqlServerDb(connectionString) : base(
34+
new DataOptions()
35+
.UseSqlServer(connectionString)
36+
.UseBeforeConnectionOpened(connection =>
37+
{
38+
connection.AccessToken = "..token here..";
39+
}))
40+
{
41+
}
4242
}
4343

4444
public class MySQLiteDb : DataConnection // or DataContext
4545
{
46-
public MySQLiteDb(connectionString) : base(
47-
new DataOptions()
48-
.UseSQLite(connectionString)
49-
.UseAfterConnectionOpened(
50-
connection =>
51-
{
52-
using var cmd = connection.CreateCommand();
53-
cmd.CommandText = $"PRAGMA KEY '{key}'";
54-
cmd.ExecuteNonQuery();
55-
},
56-
// optionally add async version to use non-blocking calls from async execution path
57-
async (connection, cancellationToken) =>
58-
{
59-
using var cmd = connection.CreateCommand();
60-
cmd.CommandText = $"PRAGMA KEY '{key}'";
61-
await cmd.ExecuteNonQueryAsync(cancellationToken);
62-
}))
63-
{
64-
}
46+
public MySQLiteDb(connectionString) : base(
47+
new DataOptions()
48+
.UseSQLite(connectionString)
49+
.UseAfterConnectionOpened(
50+
connection =>
51+
{
52+
using var cmd = connection.CreateCommand();
53+
cmd.CommandText = $"PRAGMA KEY '{key}'";
54+
cmd.ExecuteNonQuery();
55+
},
56+
// optionally add async version to use non-blocking calls from async execution path
57+
async (connection, cancellationToken) =>
58+
{
59+
using var cmd = connection.CreateCommand();
60+
cmd.CommandText = $"PRAGMA KEY '{key}'";
61+
await cmd.ExecuteNonQueryAsync(cancellationToken);
62+
}))
63+
{
64+
}
6565
}
6666

6767
using (var db = new MySqlServerDb())
6868
{
69-
// queries here will get pre-configured connection
69+
// queries here will get pre-configured connection
7070
}
7171
```
7272

@@ -119,12 +119,12 @@ For .NET Framework you just need to add assembly bindings redirect to your confi
119119

120120
```xml
121121
<runtime>
122-
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
122+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
123123
<dependentAssembly>
124-
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral"/>
125-
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
124+
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral"/>
125+
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
126126
</dependentAssembly>
127-
</assemblyBinding>
127+
</assemblyBinding>
128128
</runtime>
129129
```
130130

@@ -141,27 +141,27 @@ AssemblyLoadContext.Default.Resolving += OnAssemblyResolve;
141141

142142
Assembly OnAssemblyResolve(AssemblyLoadContext assemblyLoadContext, AssemblyName assemblyName)
143143
{
144-
try
145-
{
146-
// you need to unsubscribe here to avoid StackOverflowException,
147-
// as LoadFromAssemblyName will go in recursion here otherwise
148-
AssemblyLoadContext.Default.Resolving -= OnAssemblyResolve;
149-
// return resolved assembly for cases when it can be resolved
150-
return assemblyLoadContext.LoadFromAssemblyName(assemblyName);
151-
}
152-
catch
153-
{
154-
// on failue - check if it failed to load our types assembly
155-
// and explicitly return it
156-
if (assemblyName.Name == "Microsoft.SqlServer.Types")
157-
return typeof(SqlGeography).Assembly;
158-
// if it failed to load some other assembly - just pass exception as-is
159-
throw;
160-
}
161-
finally
162-
{
163-
// don't forget to restore our load handler
164-
AssemblyLoadContext.Default.Resolving += OnAssemblyResolve;
165-
}
144+
try
145+
{
146+
// you need to unsubscribe here to avoid StackOverflowException,
147+
// as LoadFromAssemblyName will go in recursion here otherwise
148+
AssemblyLoadContext.Default.Resolving -= OnAssemblyResolve;
149+
// return resolved assembly for cases when it can be resolved
150+
return assemblyLoadContext.LoadFromAssemblyName(assemblyName);
151+
}
152+
catch
153+
{
154+
// on failue - check if it failed to load our types assembly
155+
// and explicitly return it
156+
if (assemblyName.Name == "Microsoft.SqlServer.Types")
157+
return typeof(SqlGeography).Assembly;
158+
// if it failed to load some other assembly - just pass exception as-is
159+
throw;
160+
}
161+
finally
162+
{
163+
// don't forget to restore our load handler
164+
AssemblyLoadContext.Default.Resolving += OnAssemblyResolve;
165+
}
166166
}
167167
```

0 commit comments

Comments
 (0)