You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: enhance documentation and features across multiple articles
- Updated threading.md to include ITimer interface and TaskExtensions for better async task handling.
- Added JsonResult for returning JSON with custom status codes in web-mvc.md.
- Introduced AuthenticatedUser and API versioning support in web.md.
- Revised intro.md to reflect updated target frameworks and added new features in various packages.
- Removed obsolete Media Image section from the table of contents.
- Updated docfx.json to target net10.0 and modified templates for a modern look.
- Created a new custom CSS file for improved styling on the landing page.
- Deleted outdated material template files to streamline the documentation structure.
- Adjusted table of contents to point to articles instead of docs.
Copy file name to clipboardExpand all lines: docs/articles/features/collections.md
+78Lines changed: 78 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,3 +158,81 @@ public async Task ProcessMessagesAsync(IEnumerable<Message> messages, Cancellati
158
158
}
159
159
}
160
160
```
161
+
162
+
There is also a `Chunk` extension for `IQueryable<T>` in the `MADE.Collections.QueryableExtensions` class, which splits a query into smaller queries for batch processing.
163
+
164
+
## Conditionally adding or removing items with AddIf and RemoveIf
165
+
166
+
The `AddIf` and `RemoveIf` extensions on `IList<T>` allow you to add or remove an item based on a condition function.
Similarly, `AddRangeIf` and `RemoveRangeIf` extensions allow you to conditionally add or remove a collection of items.
176
+
177
+
## Inserting items at a sorted position with InsertAtPotentialIndex
178
+
179
+
The `InsertAtPotentialIndex` extension on `IList<T>` inserts an item at the position determined by a predicate, useful for maintaining sorted collections.
The companion `PotentialIndexOf` extension returns the index without inserting, if you need to determine the position first.
189
+
190
+
## Shuffling a collection with the Shuffle extension
191
+
192
+
The `Shuffle` extension randomly reorders the elements of an `IEnumerable<T>`.
193
+
194
+
```csharp
195
+
varshuffled=myItems.Shuffle();
196
+
```
197
+
198
+
## Sorting an ObservableCollection with Sort and SortDescending
199
+
200
+
`ObservableCollection<T>` objects don't have built-in sorting. The `Sort` and `SortDescending` extensions allow you to sort in place while correctly raising collection changed events.
Copy file name to clipboardExpand all lines: docs/articles/features/data-converters.md
+57-58Lines changed: 57 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,17 +7,26 @@ title: Using the Data Converters package
7
7
8
8
The Data Converters package provides a collection of value converters and extensions to manipulate data in your applications.
9
9
10
-
## Converting a DateTime to a String using the DateTimeToStringValueConverter
10
+
## Converting a bool to a String using the BooleanToStringValueConverter
11
11
12
-
Value converters are a common coding practice for building XAML applications that allow values to be bound to a view, converted to a different type and back depending on the binding mode.
12
+
The `MADE.Data.Converters.BooleanToStringValueConverter` converts `bool`values to configurable `String` representations using the `TrueValue`and `FalseValue` properties.
13
13
14
-
Why should that be limited to just XAML applications though?
14
+
```csharp
15
+
varconverter=newBooleanToStringValueConverter
16
+
{
17
+
TrueValue="Yes",
18
+
FalseValue="No"
19
+
};
15
20
16
-
The `MADE.Data.Converters.DateTimeToStringValueConverter` works across any .NET application, including your XAML bindings.
It converts a `DateTime` value to a `String` using a format parameter. The format parameter must be a valid `DateTime` string format [based on the Microsoft documentation](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).
25
+
## Converting a DateTime to a String using the DateTimeToStringValueConverter
26
+
27
+
The `MADE.Data.Converters.DateTimeToStringValueConverter` converts a `DateTime` value to a `String` using a format parameter. The format parameter must be a valid `DateTime` string format [based on the Microsoft documentation](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).
19
28
20
-
Below is an example of this in use in any C# application.
29
+
Below is an example of this in use.
21
30
22
31
```csharp
23
32
namespaceApp.Conversions
@@ -41,67 +50,57 @@ namespace App.Conversions
41
50
}
42
51
```
43
52
44
-
You can also take advantage of this converter in your XAML applications too.
If you want to take advantage of what goes into a value converter, you can build your own using the `MADE.Data.Converters.IValueConverter` interface which provides the signatures for the `Convert` and `ConvertBack` methods.
55
+
If you want to take advantage of what goes into a value converter, you can build your own using the `MADE.Data.Converters.IValueConverter<TFrom, TTo>` interface which provides the signatures for the `Convert` and `ConvertBack` methods.
70
56
71
57
These can be used to convert any type to another. Whatever data conversion you think you may need, you'll be able to build out a value converter to satisfy that need for your project.
72
58
73
-
You can then build out your own, similar to our `DateTimeToStringValueConverter`.
59
+
If there is a common value converter you think is missing from MADE.NET, [raise a tracking item on GitHub](https://github.com/MADE-Apps/MADE.NET/issues/new/choose) and we'll get it implemented.
The `MADE.Data.Converters.Extensions.StringExtensions` class provides extensions for manipulating `String` values:
77
+
78
+
-`ToTitleCase()` - Converts a string to title case.
79
+
-`ToDefaultCase()` - Converts a string to default (lower) case.
80
+
-`Truncate()` - Truncates a string to a specified length.
81
+
-`ToBase64()` / `FromBase64()` - Converts to and from Base64 encoding.
82
+
-`ToMemoryStreamAsync()` - Converts a string to a `MemoryStream`.
83
+
-`ToInt()` / `ToNullableInt()` - Parses a string to an integer.
84
+
-`ToFloat()` / `ToNullableFloat()` - Parses a string to a float.
85
+
-`ToDouble()` / `ToNullableDouble()` - Parses a string to a double.
86
+
-`ToBoolean()` - Parses a string to a boolean.
87
+
88
+
## Boolean extensions
89
+
90
+
The `MADE.Data.Converters.Extensions.BooleanExtensions` class provides the `ToFormattedString` extension for formatting `bool` values to custom string representations.
If you want to build a XAML specific value converter, you can also apply the `Windows.UI.Xaml.Data.IValueConverter` to your class and implement the additional methods calling directly into your `Convert` and `ConvertBack` methods.
97
+
## Math extensions
106
98
107
-
If there is a common value converter you think is missing from MADE.NET, [raise a tracking item on GitHub](https://github.com/MADE-Apps/MADE.NET/issues/new/choose) and we'll get it implemented.
99
+
The `MADE.Data.Converters.Extensions.MathExtensions` class provides extensions for common mathematic expressions including `ToRadians` to convert a degrees value to radians.
100
+
101
+
## Length extensions
102
+
103
+
The `MADE.Data.Converters.Extensions.LengthExtensions` class provides extensions for converting length values:
104
+
105
+
-`ToMeters()` - Converts a value from miles to meters.
106
+
-`ToMiles()` - Converts a value from meters to miles.
Copy file name to clipboardExpand all lines: docs/articles/features/data-efcore.md
+71-4Lines changed: 71 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
uid: package-data-converters
3
-
title: Using the Data Converters package
2
+
uid: package-data-efcore
3
+
title: Using the Data EF Core package
4
4
---
5
5
6
6
# Using the Data Entity Framework Core package
@@ -17,9 +17,9 @@ These are:
17
17
- A date the entity was created
18
18
- A date the entity was last updated
19
19
20
-
This is what the `MADE.Data.EFCore.EntityBase` type provides for you. It even goes as far as to initialize your created and last updated date values for you when you create your object.
20
+
This is what the `MADE.Data.EFCore.EntityBase` type provides for you. It initializes your created and last updated date values when you create your object.
21
21
22
-
To use it for your own entities, it's as simple as inheriting from the `EntityBase` type.
22
+
To use it for your own entities, inherit from the `EntityBase` type. By default, it uses a `Guid` identifier.
23
23
24
24
```csharp
25
25
namespaceMyApp.Data
@@ -36,3 +36,70 @@ namespace MyApp.Data
36
36
}
37
37
}
38
38
```
39
+
40
+
### Using a custom key type with EntityBase
41
+
42
+
If you need a different identifier type, use the generic `EntityBase<TKey>`:
43
+
44
+
```csharp
45
+
publicclassProduct : EntityBase<int>
46
+
{
47
+
publicstringName { get; set; }
48
+
49
+
publicdecimalPrice { get; set; }
50
+
}
51
+
```
52
+
53
+
### Entity interfaces
54
+
55
+
The following interfaces are available for implementing custom entity types:
56
+
57
+
-`IDatedEntity` - Defines `CreatedDate` and `UpdatedDate` properties.
58
+
-`IEntityBase<TKey>` - Extends `IDatedEntity` with a typed `Id` property.
59
+
-`IEntityBase` - A convenience interface that uses `Guid` as the key type.
60
+
61
+
## Configuring entities with EntityBaseExtensions
62
+
63
+
The `MADE.Data.EFCore.Extensions.EntityBaseExtensions` class provides extensions for configuring entity types in your `DbContext` model builder.
0 commit comments