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
Copy file name to clipboardexpand all lines: README.md
+61-3
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,8 @@ This is the home repository for the Asp.net Core version of the [Mvc Controls
3
3
Toolkit](http://mvccontrolstoolkit.codeplex.com/). Here you will find all features, some examples, and the future Roadmap.
4
4
5
5
## First public release
6
-
The first public release will be Asp.net Core Rc2 compatible, and will be available in a few days: we are moving rc1 bits
7
-
to rc2 and we are preparing examples and live demos.
8
-
This release will contain the following features:
6
+
The public release of the tookit, First Asp.net Core Rc2 compatible, is out! in a few day documentation, examples and live demos!
7
+
This release contain the following features:
9
8
10
9
11
10
1. A [business module](https://github.com/MvcControlsToolkit/MvcControlsToolkit.Core/tree/master/src/MvcControlsToolkit.Core.Business) that has no reference to asp.net dlls, containing:
@@ -24,6 +23,61 @@ and may be converted into Datetimes by simply assigning them to a Datetime var.
24
23
25
24
* A `RequiredFielsAttribute`. A class level annotation that accepts a comma separated list of property names, and declares they are required.
26
25
Each property may be also an IEnumerable, in which case it is considered invalid when it is either null or empty.
26
+
* LinQ productivity tools, more specifically:
27
+
28
+
1) a projection operator(in MvcControlsToolkit.Core.LinQ) to project LinQ queries into ViewModels without being forced to copy manually all properties. It works
29
+
Like:
30
+
```C#
31
+
db.MyTable.Where(...)...Project().To<MyViewModel>(m => new MyViewModel{FullName = m.Name+' ' +m.Surname})
32
+
```
33
+
That is, you need to specify just the exceptions from normal property copying, or just `To<MyViewModel>()` if there are no exceptions.
34
+
One level nested objects are accessed automatically by concatenating the main object and child object property names in the ViewModel.
35
+
So, for instance, if I am retrieving `OrderItem` objects that contain the father order into a property named `Order` you can get the `Number` property of the Order object,
36
+
by adding a `OrderNumber` property to your ViewModel. The projection operator is implemented efficiently and rely on 2 caches
37
+
to speed up LinQ expressions automatic creation.
38
+
39
+
2) A `ChangeSet` object (MvcControlsToolkit.Core.Business.Utilities) to help moving changes performed in the user interface into the database. You may create a new `ChangeSet` by calling
40
+
the static `Create` property of the `ChangeSet` class:
Inserted, Modified, Unmodified, and Deleted objects are detected by comparing the ViewModel lists before,and after modifications. The `oldValues` list
48
+
may be saved by adding an old values section to your View ViewModel and saving it with the help of the `<save-model/>` tag helper (see below the MvcControlsToolkit.Core dll)
49
+
`keyExpression` specifies the property that works as a principal key. The principal key may contain a null value in the case of newly added objects.
50
+
If `veriFyChangedProperies` is `true` old and new values of properties are checked to verify if ViewModels that are not Deleted, nor
51
+
Inserted are Modified or Unmodified, otherwise all that ViewModels are assumed to be Modified. IEnumerable properties possibly containing child objects,
52
+
are not taken into account during this processing, so possible children entities must be processed either manually or by using other `ChangeSet` objects.
53
+
Once created a `ChangeSet` object you may either handle manually the Inserted, Modified, Unmodified,
54
+
and Deleted lists or call its `UpdateDatabase` method.
55
+
```C#
56
+
public async Task<List<M>> UpdateDatabase(DbSet<M> table, DbContext ctx,
Where: `M` is the database class (different from the ViewModel the ChangeSet is based on).
61
+
`accessExpression` is an expression used to verify "access rights" to modify or delete each entity.
62
+
For instance, if we are modifying "task" items we need to verify that the logged user is the owner of the task with an
63
+
`accessExpression` like: `m => m.OwnerId == loggedUserId`. If `saveChanges` is `true``DbContext` changes are saved
64
+
automatically after the update, and the possibly newly created keys of the inserted objects are copied into the
65
+
associated ViewModels of the Inserted list. If `retrieveChanged` is `true` (the default) the changed objects are retireved
66
+
from the database and changed poperties in the associated ViewModels are copied into them, otherwise new instances
67
+
of `M` are created, attached to the context as "changed" and Changed ViewMdels are copied into them. `retrieveChanged = false`
68
+
may speed up the update when ViewModels contain substantially all properies of `M`, otherwise we are forced to set `retrieveChanged = true`.
69
+
The method returns the newly created database objects. This list is useful to get the newly created keys in case we set `saveChanges = false` so
70
+
they cant be copied automatically in the original ViewModels.
71
+
The `ChangeSet` object may be used also when we need to Insert, Delete, or Save a sigle object. Namely,
72
+
for a single insert just put a single object in the `newValues` list and set the `oldValues` list to null.
73
+
For a single delete just do the contrary. For a single changed object, if the old copy is available
74
+
put the old copy in the `oldValues` list and the modified copy in the `newValues` list, otherwise put the same object
75
+
in both lists and set `verifyChangedProperties = false`.
76
+
77
+
3) The `MvcControlsToolkit.Core.Business.Utilities.ObjectCopier<M, T>` object to copy properties
78
+
with the same name form an instance of `M` to an instanceof `T`. Once created an instance of `ObjectCopier<M, T>`
79
+
may be used in several copy operatons. It is worth saving instances of `ObjectCopier<M, T>`,
80
+
since during its creation it performs costly reflection operations.
27
81
2.[An option Module](https://github.com/MvcControlsToolkit/MvcControlsToolkit.Core/tree/master/src/MvcControlsToolkit.Core.Options) that uses several providers to fill an hierarchical options dictionary.
28
82
It has the purpose of adapting request processing to the current environment: browser capabilities, logged user, explicitely specified preferences, and overall application settings.
29
83
The option dictionary is used to fill option classes that are injected wherever Asp.net Core accepts injection.
0 commit comments