Skip to content

Commit e4851ae

Browse files
Format identifiers as code (#2887)
* Update proxies.md * Update async.md
1 parent 80e6c54 commit e4851ae

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

entity-framework/ef6/fundamentals/async.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ Now that we have an EF model, let's write some code that uses it to perform some
131131
}
132132
```
133133

134-
This code calls the **PerformDatabaseOperations** method which saves a new **Blog** to the database and then retrieves all **Blogs** from the database and prints them to the **Console**. After this, the program writes a quote of the day to the **Console**.
134+
This code calls the `PerformDatabaseOperations` method which saves a new **Blog** to the database and then retrieves all **Blogs** from the database and prints them to the **Console**. After this, the program writes a quote of the day to the **Console**.
135135

136136
Since the code is synchronous, we can observe the following execution flow when we run the program:
137137

138-
1. **SaveChanges** begins to push the new **Blog** to the database
139-
2. **SaveChanges** completes
138+
1. `SaveChanges` begins to push the new **Blog** to the database
139+
2. `SaveChanges` completes
140140
3. Query for all **Blogs** is sent to the database
141141
4. Query returns and results are written to **Console**
142142
5. Quote of the day is written to **Console**
@@ -149,14 +149,14 @@ Since the code is synchronous, we can observe the following execution flow when
149149

150150
Now that we have our program up and running, we can begin making use of the new async and await keywords. We've made the following changes to Program.cs
151151

152-
1. Line 2: The using statement for the **System.Data.Entity** namespace gives us access to the EF async extension methods.
153-
2. Line 4: The using statement for the **System.Threading.Tasks** namespace allows us to use the **Task** type.
154-
3. Line 12 & 18: We are capturing as task that monitors the progress of **PerformSomeDatabaseOperations** (line 12) and then blocking program execution for this task to complete once all the work for the program is done (line 18).
155-
4. Line 25: We've update **PerformSomeDatabaseOperations** to be marked as **async** and return a **Task**.
156-
5. Line 35: We're now calling the Async version of SaveChanges and awaiting it's completion.
157-
6. Line 42: We're now calling the Async version of ToList and awaiting on the result.
152+
1. Line 2: The using statement for the `System.Data.Entity` namespace gives us access to the EF async extension methods.
153+
2. Line 4: The using statement for the `System.Threading.Tasks` namespace allows us to use the `Task` type.
154+
3. Line 12 & 18: We are capturing as task that monitors the progress of `PerformSomeDatabaseOperations` (line 12) and then blocking program execution for this task to complete once all the work for the program is done (line 18).
155+
4. Line 25: We've update `PerformSomeDatabaseOperations` to be marked as `async` and return a `Task`.
156+
5. Line 35: We're now calling the Async version of `SaveChanges` and awaiting it's completion.
157+
6. Line 42: We're now calling the Async version of `ToList` and awaiting on the result.
158158

159-
For a comprehensive list of available extension methods in the System.Data.Entity namespace, refer to the QueryableExtensions class. *You’ll also need to add using System.Data.Entity to your using statements.*
159+
For a comprehensive list of available extension methods in the `System.Data.Entity` namespace, refer to the `QueryableExtensions` class. *You’ll also need to add `using System.Data.Entity` to your using statements.*
160160

161161
``` csharp
162162
using System;
@@ -216,11 +216,11 @@ For a comprehensive list of available extension methods in the System.Data.Entit
216216

217217
Now that the code is asynchronous, we can observe a different execution flow when we run the program:
218218

219-
1. **SaveChanges** begins to push the new **Blog** to the database
220-
*Once the command is sent to the database no more compute time is needed on the current managed thread. The **PerformDatabaseOperations** method returns (even though it hasn't finished executing) and program flow in the Main method continues.*
219+
1. `SaveChanges` begins to push the new **Blog** to the database
220+
*Once the command is sent to the database no more compute time is needed on the current managed thread. The `PerformDatabaseOperations` method returns (even though it hasn't finished executing) and program flow in the Main method continues.*
221221
2. **Quote of the day is written to Console**
222-
*Since there is no more work to do in the Main method, the managed thread is blocked on the Wait call until the database operation completes. Once it completes, the remainder of our **PerformDatabaseOperations** will be executed.*
223-
3. **SaveChanges** completes
222+
*Since there is no more work to do in the Main method, the managed thread is blocked on the `Wait` call until the database operation completes. Once it completes, the remainder of our `PerformDatabaseOperations` will be executed.*
223+
3. `SaveChanges` completes
224224
4. Query for all **Blogs** is sent to the database
225225
*Again, the managed thread is free to do other work while the query is processed in the database. Since all other execution has completed, the thread will just halt on the Wait call though.*
226226
5. Query returns and results are written to **Console**

entity-framework/ef6/fundamentals/proxies.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ When creating instances of POCO entity types, Entity Framework often creates ins
1010

1111
## Disabling proxy creation
1212

13-
Sometimes it is useful to prevent Entity Framework from creating proxy instances. For example, serializing non-proxy instances is considerably easier than serializing proxy instances. Proxy creation can be turned off by clearing the ProxyCreationEnabled flag. One place you could do this is in the constructor of your context. For example:
13+
Sometimes it is useful to prevent Entity Framework from creating proxy instances. For example, serializing non-proxy instances is considerably easier than serializing proxy instances. Proxy creation can be turned off by clearing the `ProxyCreationEnabled` flag. One place you could do this is in the constructor of your context. For example:
1414

1515
``` csharp
1616
public class BloggingContext : DbContext
@@ -29,7 +29,7 @@ Note that the EF will not create proxies for types where there is nothing for th
2929

3030
## Explicitly creating an instance of a proxy
3131

32-
A proxy instance will not be created if you create an instance of an entity using the new operator. This may not be a problem, but if you need to create a proxy instance (for example, so that lazy loading or proxy change tracking will work) then you can do so using the Create method of DbSet. For example:
32+
A proxy instance will not be created if you create an instance of an entity using the new operator. This may not be a problem, but if you need to create a proxy instance (for example, so that lazy loading or proxy change tracking will work) then you can do so using the `Create` method of `DbSet`. For example:
3333

3434
``` csharp
3535
using (var context = new BloggingContext())
@@ -38,7 +38,7 @@ using (var context = new BloggingContext())
3838
}
3939
```
4040

41-
The generic version of Create can be used if you want to create an instance of a derived entity type. For example:
41+
The generic version of `Create` can be used if you want to create an instance of a derived entity type. For example:
4242

4343
``` csharp
4444
using (var context = new BloggingContext())
@@ -47,17 +47,19 @@ using (var context = new BloggingContext())
4747
}
4848
```
4949

50-
Note that the Create method does not add or attach the created entity to the context.
50+
Note that the `Create` method does not add or attach the created entity to the context.
5151

52-
Note that the Create method will just create an instance of the entity type itself if creating a proxy type for the entity would have no value because it would not do anything. For example, if the entity type is sealed and/or has no virtual properties then Create will just create an instance of the entity type.
52+
Note that the `Create` method will just create an instance of the entity type itself if creating a proxy type for the entity would have no value because it would not do anything. For example, if the entity type is sealed and/or has no virtual properties then `Create` will just create an instance of the entity type.
5353

5454
## Getting the actual entity type from a proxy type
5555

5656
Proxy types have names that look something like this:
5757

58-
System.Data.Entity.DynamicProxies.Blog_5E43C6C196972BF0754973E48C9C941092D86818CD94005E9A759B70BF6E48E6
58+
```
59+
System.Data.Entity.DynamicProxies.Blog_5E43C6C196972BF0754973E48C9C941092D86818CD94005E9A759B70BF6E48E6
60+
```
5961

60-
You can find the entity type for this proxy type using the GetObjectType method from ObjectContext. For example:
62+
You can find the entity type for this proxy type using the `GetObjectType` method from `ObjectContext`. For example:
6163

6264
``` csharp
6365
using (var context = new BloggingContext())
@@ -67,4 +69,4 @@ using (var context = new BloggingContext())
6769
}
6870
```
6971

70-
Note that if the type passed to GetObjectType is an instance of an entity type that is not a proxy type then the type of entity is still returned. This means you can always use this method to get the actual entity type without any other checking to see if the type is a proxy type or not.
72+
Note that if the type passed to `GetObjectType` is an instance of an entity type that is not a proxy type then the type of entity is still returned. This means you can always use this method to get the actual entity type without any other checking to see if the type is a proxy type or not.

0 commit comments

Comments
 (0)