Skip to content

Commit 44a6792

Browse files
committed
docs: more tlc
1 parent daea43d commit 44a6792

File tree

2 files changed

+42
-20
lines changed

2 files changed

+42
-20
lines changed

README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class Startup
7878
}
7979
}
8080
```
81-
> 💡 Pro-tip: `UseQueryableValues` offers an optional `options` delegate for additional configurations.
81+
> 💡 `UseQueryableValues` offers an optional `options` delegate for additional configurations.
8282
8383
## How Do You Use It?
8484
The `AsQueryableValues` extension method is provided by the `BlazarTech.QueryableValues` namespace; therefore, you must add the following `using` directive to your source code file for it to appear as a method of your [DbContext] instance:
@@ -92,8 +92,7 @@ Below are a few examples composing a query using the values provided by an [IEnu
9292

9393
### Simple Type Examples
9494

95-
> 💡 Supported types:
96-
> [Byte], [Int16], [Int32], [Int64], [Decimal], [Single], [Double], [DateTime], [DateTimeOffset], [Guid], [Char], and [String].
95+
> 💡 Supports [Byte], [Int16], [Int32], [Int64], [Decimal], [Single], [Double], [DateTime], [DateTimeOffset], [Guid], [Char], and [String].
9796
9897
Using the [Contains][ContainsQueryable] LINQ method:
9998

@@ -155,18 +154,29 @@ var myQuery2 =
155154
```
156155
### Complex Type Example
157156

158-
> 💡 Requirements:
159-
> - Can be an anonymous type.
160-
> - Can be a user-defined class or struct with read/write properties and a public constructor.
161-
> - Must have one or more simple type properties, including [Boolean].
157+
> 💡 Must be an anonymous or user-defined type with one or more simple type properties, including [Boolean].
162158
163159
```c#
164160
// Performance Tip:
165161
// If your IEnumerable<T> item type (T) has many properties, project only
166162
// the ones you need to a new variable and use it in your query.
167163
var projectedItems = items.Select(i => new { i.CategoryId, i.ColorName });
168164

169-
var myQuery =
165+
// Example #1 (LINQ method syntax)
166+
var myQuery1 = dbContext.Product
167+
.Join(
168+
dbContext.AsQueryableValues(projectedItems),
169+
p => new { p.CategoryId, p.ColorName },
170+
pi => new { pi.CategoryId, pi.ColorName },
171+
(p, pi) => new
172+
{
173+
p.ProductId,
174+
p.Description
175+
}
176+
);
177+
178+
// Example #2 (LINQ query syntax)
179+
var myQuery2 =
170180
from p in dbContext.Product
171181
join pi in dbContext.AsQueryableValues(projectedItems) on new { p.CategoryId, p.ColorName } equals new { pi.CategoryId, pi.ColorName }
172182
select new
@@ -175,10 +185,11 @@ var myQuery =
175185
p.Description
176186
};
177187
```
188+
178189
**About Complex Types**
179-
> :warning: All the data provided by this type is transmitted to the server; therefore, ensure that it only contains the properties you need for your query. Not following this recommendation will degrade the query's performance.
190+
> ⚠️ All the data provided by this type is transmitted to the server; therefore, ensure that it only contains the properties you need for your query. Not following this recommendation will degrade the query's performance.
180191
181-
> :warning: There is a limit of up to 10 properties for any given simple type (e.g. cannot have more than 10 [Int32] properties). Exceeding that limit will cause an exception and may also suggest that you should rethink your strategy.
192+
> ⚠️ There is a limit of up to 10 properties for any given simple type (e.g. cannot have more than 10 [Int32] properties). Exceeding that limit will cause an exception and may also suggest that you should rethink your strategy.
182193
183194
# Benchmarks
184195
The following [benchmarks] consist of simple EF Core queries that have a dependency on a random sequence of [Int32], [Guid], and [String] values via the `Contains` LINQ method. It shows the performance differences between not using and using QueryableValues. In practice, the benefits of using QueryableValues are more dramatic on complex EF Core queries and busy environments.

docs/README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class Startup
7474
}
7575
}
7676
```
77-
> 💡 Pro-tip: `UseQueryableValues` offers an optional `options` delegate for additional configurations.
77+
> 💡 `UseQueryableValues` offers an optional `options` delegate for additional configurations.
7878
7979
## How Do You Use It?
8080
The `AsQueryableValues` extension method is provided by the `BlazarTech.QueryableValues` namespace; therefore, you must add the following `using` directive to your source code file for it to appear as a method of your [DbContext] instance:
@@ -88,8 +88,7 @@ Below are a few examples composing a query using the values provided by an [IEnu
8888

8989
### Simple Type Examples
9090

91-
> 💡 Supported types:
92-
> [Byte], [Int16], [Int32], [Int64], [Decimal], [Single], [Double], [DateTime], [DateTimeOffset], [Guid], [Char], and [String].
91+
> 💡 Supports [Byte], [Int16], [Int32], [Int64], [Decimal], [Single], [Double], [DateTime], [DateTimeOffset], [Guid], [Char], and [String].
9392
9493
Using the [Contains][ContainsQueryable] LINQ method:
9594

@@ -151,18 +150,29 @@ var myQuery2 =
151150
```
152151
### Complex Type Example
153152

154-
> 💡 Requirements:
155-
> - Can be an anonymous type.
156-
> - Can be a user-defined class or struct with read/write properties and a public constructor.
157-
> - Must have one or more simple type properties, including [Boolean].
153+
> 💡 Must be an anonymous or user-defined type with one or more simple type properties, including [Boolean].
158154
159155
```c#
160156
// Performance Tip:
161157
// If your IEnumerable<T> item type (T) has many properties, project only
162158
// the ones you need to a new variable and use it in your query.
163159
var projectedItems = items.Select(i => new { i.CategoryId, i.ColorName });
164160

165-
var myQuery =
161+
// Example #1 (LINQ method syntax)
162+
var myQuery1 = dbContext.Product
163+
.Join(
164+
dbContext.AsQueryableValues(projectedItems),
165+
p => new { p.CategoryId, p.ColorName },
166+
pi => new { pi.CategoryId, pi.ColorName },
167+
(p, pi) => new
168+
{
169+
p.ProductId,
170+
p.Description
171+
}
172+
);
173+
174+
// Example #2 (LINQ query syntax)
175+
var myQuery2 =
166176
from p in dbContext.Product
167177
join pi in dbContext.AsQueryableValues(projectedItems) on new { p.CategoryId, p.ColorName } equals new { pi.CategoryId, pi.ColorName }
168178
select new
@@ -171,10 +181,11 @@ var myQuery =
171181
p.Description
172182
};
173183
```
184+
174185
**About Complex Types**
175-
> :warning: All the data provided by this type is transmitted to the server; therefore, ensure that it only contains the properties you need for your query. Not following this recommendation will degrade the query's performance.
186+
> ⚠️ All the data provided by this type is transmitted to the server; therefore, ensure that it only contains the properties you need for your query. Not following this recommendation will degrade the query's performance.
176187
177-
> :warning: There is a limit of up to 10 properties for any given simple type (e.g. cannot have more than 10 [Int32] properties). Exceeding that limit will cause an exception and may also suggest that you should rethink your strategy.
188+
> ⚠️ There is a limit of up to 10 properties for any given simple type (e.g. cannot have more than 10 [Int32] properties). Exceeding that limit will cause an exception and may also suggest that you should rethink your strategy.
178189
179190
## Do You Want To Know More? 📚
180191
Please take a look at the [repository][Repository].

0 commit comments

Comments
 (0)