diff options
| author | Roy <roy.mail.net@gmail.com> | 2017-12-17 22:32:16 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2017-12-17 22:32:16 +0200 |
| commit | 5e19a309af8eab0a8df9090459fbd3d8c31db3cc (patch) | |
| tree | b4b5a89431dc468531d34f00a5e37ff4dcb92279 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs | |
| parent | 1d9247ecb3af34b7a509f46550efcb621817fa4a (diff) | |
| download | Tango-5e19a309af8eab0a8df9090459fbd3d8c31db3cc.tar.gz Tango-5e19a309af8eab0a8df9090459fbd3d8c31db3cc.zip | |
Implemented auto generated observable entities adapter extensions on build.
Implemented smart filtering of DB views.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs index 08a455c81..b6d77748e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs @@ -15,6 +15,7 @@ using Tango.MachineStudio.DB.Messages; using System.Collections.ObjectModel; using System.Reflection; using Tango.MachineStudio.Common.StudioApplication; +using System.ComponentModel; namespace Tango.MachineStudio.DB.ViewModels { @@ -289,7 +290,21 @@ namespace Tango.MachineStudio.DB.ViewModels protected virtual void OnFilterChanged(String filter) { + String viewSourceName = this.GetType().Name.Replace("ViewVM", "ViewSource"); + ICollectionView collectionView = Adapter.GetType().GetProperty(viewSourceName).GetValue(Adapter) as ICollectionView; + collectionView.Filter = (entity) => + { + return + entity. + GetType(). + GetProperties(BindingFlags.Public | BindingFlags.Instance). + Where(x => x.Name != "Deleted" && x.Name != "ID" && x.Name != "LastUpdated"). + Where(x => !x.PropertyType.IsGenericType && (x.PropertyType.IsClass || x.PropertyType == typeof(String))). + Select(prop => prop.GetValue(entity).ToString()). + ToList(). + Any(x => x.ToLower().Contains(filter.ToLower())); + }; } protected virtual void InitializeEntity(T entity) |
