Example #1
0
 public object Post(DataPropertySearch request) => Get(request);
Example #2
0
 public object Get(DataPropertySearch request) => GetSearchResultWithCache <DataProperty, DocEntityDataProperty, DataPropertySearch>(DocConstantModelName.DATAPROPERTY, request, _ExecSearch);
Example #3
0
        private IQueryable <DocEntityDataProperty> _ExecSearch(DataPropertySearch request, DocQuery query)
        {
            request = InitSearch <DataProperty, DataPropertySearch>(request);
            IQueryable <DocEntityDataProperty> entities = null;

            query.Run(session =>
            {
                entities = query.SelectAll <DocEntityDataProperty>();
                if (!DocTools.IsNullOrEmpty(request.FullTextSearch))
                {
                    var fts  = new DataPropertyFullTextSearch(request);
                    entities = GetFullTextSearch <DocEntityDataProperty, DataPropertyFullTextSearch>(fts, entities);
                }

                if (null != request.Ids && request.Ids.Any())
                {
                    entities = entities.Where(en => en.Id.In(request.Ids));
                }

                if (!DocTools.IsNullOrEmpty(request.Updated))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated.Value.Date == request.Updated.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedBefore))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated <= request.UpdatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.UpdatedAfter))
                {
                    entities = entities.Where(e => null != e.Updated && e.Updated >= request.UpdatedAfter);
                }
                if (!DocTools.IsNullOrEmpty(request.Created))
                {
                    entities = entities.Where(e => null != e.Created && e.Created.Value.Date == request.Created.Value.Date);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedBefore))
                {
                    entities = entities.Where(e => null != e.Created && e.Created <= request.CreatedBefore);
                }
                if (!DocTools.IsNullOrEmpty(request.CreatedAfter))
                {
                    entities = entities.Where(e => null != e.Created && e.Created >= request.CreatedAfter);
                }
                if (true == request.Archived?.Any() && currentUser.HasProperty(DocConstantModelName.DATAPROPERTY, nameof(Reference.Archived), DocConstantPermission.VIEW))
                {
                    entities = entities.Where(en => en.Archived.In(request.Archived));
                }
                else
                {
                    entities = entities.Where(en => !en.Archived);
                }
                if (true == request.Locked?.Any())
                {
                    entities = entities.Where(en => en.Locked.In(request.Locked));
                }
                if (true == request.AutoCreateMissing?.Any())
                {
                    entities = entities.Where(en => en.AutoCreateMissing.In(request.AutoCreateMissing));
                }
                if (true == request.ChildrenIds?.Any())
                {
                    entities = entities.Where(en => en.Children.Any(r => r.Id.In(request.ChildrenIds)));
                }
                if (!DocTools.IsNullOrEmpty(request.Class) && !DocTools.IsNullOrEmpty(request.Class.Id))
                {
                    entities = entities.Where(en => en.Class.Id == request.Class.Id);
                }
                if (true == request.ClassIds?.Any())
                {
                    entities = entities.Where(en => en.Class.Id.In(request.ClassIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Description))
                {
                    entities = entities.Where(en => en.Description.Contains(request.Description));
                }
                if (!DocTools.IsNullOrEmpty(request.Descriptions))
                {
                    entities = entities.Where(en => en.Description.In(request.Descriptions));
                }
                if (!DocTools.IsNullOrEmpty(request.DisplayName))
                {
                    entities = entities.Where(en => en.DisplayName.Contains(request.DisplayName));
                }
                if (!DocTools.IsNullOrEmpty(request.DisplayNames))
                {
                    entities = entities.Where(en => en.DisplayName.In(request.DisplayNames));
                }
                if (true == request.IsAllowAddInForm?.Any())
                {
                    entities = entities.Where(en => en.IsAllowAddInForm.In(request.IsAllowAddInForm));
                }
                if (true == request.IsAllowCreateInForm?.Any())
                {
                    entities = entities.Where(en => en.IsAllowCreateInForm.In(request.IsAllowCreateInForm));
                }
                if (true == request.IsAllowEditInForm?.Any())
                {
                    entities = entities.Where(en => en.IsAllowEditInForm.In(request.IsAllowEditInForm));
                }
                if (true == request.IsAllowFreeText?.Any())
                {
                    entities = entities.Where(en => en.IsAllowFreeText.In(request.IsAllowFreeText));
                }
                if (true == request.IsAllowRemoveInForm?.Any())
                {
                    entities = entities.Where(en => en.IsAllowRemoveInForm.In(request.IsAllowRemoveInForm));
                }
                if (true == request.IsAudited?.Any())
                {
                    entities = entities.Where(en => en.IsAudited.In(request.IsAudited));
                }
                if (true == request.IsCompressed?.Any())
                {
                    entities = entities.Where(en => en.IsCompressed.In(request.IsCompressed));
                }
                if (true == request.IsDisplayInForm?.Any())
                {
                    entities = entities.Where(en => en.IsDisplayInForm.In(request.IsDisplayInForm));
                }
                if (true == request.IsDisplayInGrid?.Any())
                {
                    entities = entities.Where(en => en.IsDisplayInGrid.In(request.IsDisplayInGrid));
                }
                if (true == request.IsEditColumn?.Any())
                {
                    entities = entities.Where(en => en.IsEditColumn.In(request.IsEditColumn));
                }
                if (true == request.IsInsertOnly?.Any())
                {
                    entities = entities.Where(en => en.IsInsertOnly.In(request.IsInsertOnly));
                }
                if (true == request.IsJSON?.Any())
                {
                    entities = entities.Where(en => en.IsJSON.In(request.IsJSON));
                }
                if (true == request.IsLazy?.Any())
                {
                    entities = entities.Where(en => en.IsLazy.In(request.IsLazy));
                }
                if (true == request.IsNullOnUpgrade?.Any())
                {
                    entities = entities.Where(en => en.IsNullOnUpgrade.In(request.IsNullOnUpgrade));
                }
                if (true == request.IsReadOnly?.Any())
                {
                    entities = entities.Where(en => en.IsReadOnly.In(request.IsReadOnly));
                }
                if (true == request.IsRelationship?.Any())
                {
                    entities = entities.Where(en => en.IsRelationship.In(request.IsRelationship));
                }
                if (true == request.IsRequired?.Any())
                {
                    entities = entities.Where(en => en.IsRequired.In(request.IsRequired));
                }
                if (true == request.IsRequiredInForm?.Any())
                {
                    entities = entities.Where(en => en.IsRequiredInForm.In(request.IsRequiredInForm));
                }
                if (true == request.IsVirtual?.Any())
                {
                    entities = entities.Where(en => en.IsVirtual.In(request.IsVirtual));
                }
                if (!DocTools.IsNullOrEmpty(request.JsonType))
                {
                    entities = entities.Where(en => en.JsonType.Contains(request.JsonType));
                }
                if (!DocTools.IsNullOrEmpty(request.JsonTypes))
                {
                    entities = entities.Where(en => en.JsonType.In(request.JsonTypes));
                }
                if (!DocTools.IsNullOrEmpty(request.LookupTableEnum) && !DocTools.IsNullOrEmpty(request.LookupTableEnum.Id))
                {
                    entities = entities.Where(en => en.LookupTableEnum.Id == request.LookupTableEnum.Id);
                }
                if (true == request.LookupTableEnumIds?.Any())
                {
                    entities = entities.Where(en => en.LookupTableEnum.Id.In(request.LookupTableEnumIds));
                }
                if (true == request.LookupTableEnumNames?.Any())
                {
                    entities = entities.Where(en => en.LookupTableEnum.Name.In(request.LookupTableEnumNames));
                }
                if (!DocTools.IsNullOrEmpty(request.Name))
                {
                    entities = entities.Where(en => en.Name.Contains(request.Name));
                }
                if (!DocTools.IsNullOrEmpty(request.Names))
                {
                    entities = entities.Where(en => en.Name.In(request.Names));
                }
                if (request.Order.HasValue)
                {
                    entities = entities.Where(en => request.Order.Value == en.Order);
                }
                if (!DocTools.IsNullOrEmpty(request.Owner) && !DocTools.IsNullOrEmpty(request.Owner.Id))
                {
                    entities = entities.Where(en => en.Owner.Id == request.Owner.Id);
                }
                if (true == request.OwnerIds?.Any())
                {
                    entities = entities.Where(en => en.Owner.Id.In(request.OwnerIds));
                }
                if (request.Precision.HasValue)
                {
                    entities = entities.Where(en => request.Precision.Value == en.Precision);
                }
                if (request.RelationshipOnOwnerRemove.HasValue)
                {
                    entities = entities.Where(en => request.RelationshipOnOwnerRemove.Value == en.RelationshipOnOwnerRemove);
                }
                if (!DocTools.IsNullOrEmpty(request.RelationshipOnOwnerRemoves))
                {
                    entities = entities.Where(en => en.RelationshipOnOwnerRemove.In(request.RelationshipOnOwnerRemoves));
                }
                if (request.RelationshipOnTargetRemove.HasValue)
                {
                    entities = entities.Where(en => request.RelationshipOnTargetRemove.Value == en.RelationshipOnTargetRemove);
                }
                if (!DocTools.IsNullOrEmpty(request.RelationshipOnTargetRemoves))
                {
                    entities = entities.Where(en => en.RelationshipOnTargetRemove.In(request.RelationshipOnTargetRemoves));
                }
                if (!DocTools.IsNullOrEmpty(request.RelationshipPairTo) && !DocTools.IsNullOrEmpty(request.RelationshipPairTo.Id))
                {
                    entities = entities.Where(en => en.RelationshipPairTo.Id == request.RelationshipPairTo.Id);
                }
                if (true == request.RelationshipPairToIds?.Any())
                {
                    entities = entities.Where(en => en.RelationshipPairTo.Id.In(request.RelationshipPairToIds));
                }
                if (request.Scale.HasValue)
                {
                    entities = entities.Where(en => request.Scale.Value == en.Scale);
                }
                if (!DocTools.IsNullOrEmpty(request.SetDefaultValue))
                {
                    entities = entities.Where(en => en.SetDefaultValue.Contains(request.SetDefaultValue));
                }
                if (!DocTools.IsNullOrEmpty(request.SetDefaultValues))
                {
                    entities = entities.Where(en => en.SetDefaultValue.In(request.SetDefaultValues));
                }
                if (!DocTools.IsNullOrEmpty(request.Tab) && !DocTools.IsNullOrEmpty(request.Tab.Id))
                {
                    entities = entities.Where(en => en.Tab.Id == request.Tab.Id);
                }
                if (true == request.TabIds?.Any())
                {
                    entities = entities.Where(en => en.Tab.Id.In(request.TabIds));
                }
                if (!DocTools.IsNullOrEmpty(request.Target) && !DocTools.IsNullOrEmpty(request.Target.Id))
                {
                    entities = entities.Where(en => en.Target.Id == request.Target.Id);
                }
                if (true == request.TargetIds?.Any())
                {
                    entities = entities.Where(en => en.Target.Id.In(request.TargetIds));
                }
                if (!DocTools.IsNullOrEmpty(request.TargetAlias))
                {
                    entities = entities.Where(en => en.TargetAlias.Contains(request.TargetAlias));
                }
                if (!DocTools.IsNullOrEmpty(request.TargetAliass))
                {
                    entities = entities.Where(en => en.TargetAlias.In(request.TargetAliass));
                }
                if (request.Type.HasValue)
                {
                    entities = entities.Where(en => request.Type.Value == en.Type);
                }
                if (!DocTools.IsNullOrEmpty(request.Types))
                {
                    entities = entities.Where(en => en.Type.In(request.Types));
                }
                if (request.UIType.HasValue)
                {
                    entities = entities.Where(en => request.UIType.Value == en.UIType);
                }
                if (!DocTools.IsNullOrEmpty(request.UITypes))
                {
                    entities = entities.Where(en => en.UIType.In(request.UITypes));
                }

                entities = ApplyFilters <DocEntityDataProperty, DataPropertySearch>(request, entities);

                if (request.Skip > 0)
                {
                    entities = entities.Skip(request.Skip.Value);
                }
                if (request.Take > 0)
                {
                    entities = entities.Take(request.Take.Value);
                }
                if (true == request?.OrderBy?.Any())
                {
                    entities = entities.OrderBy(request.OrderBy);
                }
                if (true == request?.OrderByDesc?.Any())
                {
                    entities = entities.OrderByDescending(request.OrderByDesc);
                }
            });
            return(entities);
        }