protected Task OnFilterChanged(string filter) { _cancellationTokenSource?.Cancel(); _cancellationTokenSource?.Dispose(); _cancellationTokenSource = new CancellationTokenSource(); var token = _cancellationTokenSource.Token; return(Task.Delay(500, token) .ContinueWith(async task => { if (task.IsCanceled) { return; } var propertyArray = SelectProperties.Split(','); var expressionArray = new string[propertyArray.Length]; for (int i = 0; i < propertyArray.Length; i++) { expressionArray[i] = $"contains({propertyArray[i]},'{filter.Replace("'", "''")}')"; } _pageRequest.Filter = string.Join(" or ", expressionArray); var page = await AdminStore.GetAsync(_pageRequest, token) .ConfigureAwait(false); EntityList = page.Items; await InvokeAsync(() => StateHasChanged()) .ConfigureAwait(false); }, TaskScheduler.Default)); }
public void AddProperty(string property) { string input = property.Trim(); if (!string.IsNullOrWhiteSpace(input)) { if (SelectProperties == null) { SelectProperties = new List <string>(); } // For backward compatibility, property can be a comma separated string of properties. We'll split and add each of them var props = input.Split(new[] { ',', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); foreach (var prop in props) { if (!SelectProperties.Contains(prop, StringComparer.InvariantCultureIgnoreCase)) { SelectProperties.Add(prop); } } SelectProperties.ForEach(e => e.ToLower()); } }
protected virtual string CreateRequestFilter(string filter) { var propertyArray = SelectProperties.Split(','); var expressionArray = new string[propertyArray.Length]; for (int i = 0; i < propertyArray.Length; i++) { expressionArray[i] = $"contains({propertyArray[i]},'{filter.Replace("'", "''")}')"; } return(string.Join(" or ", expressionArray)); }
protected override Expression VisitNew(NewExpression node) { foreach (MemberExpression propertyExpression in node.Arguments.OfType <MemberExpression>()) { var property = (PropertyInfo)propertyExpression.Member; if (Parsers.OeExpressionHelper.IsEntityType(property.PropertyType)) { SelectProperties.Add(property); } } return(node); }
protected internal void AddSelectProperty(string property) { string trimmedProperty = property.Trim(); if (SelectProperties == null) { SelectProperties = new List <string>(); } if (!SelectProperties.Contains(trimmedProperty, StringComparer.InvariantCultureIgnoreCase)) { SelectProperties.Add(trimmedProperty); } }
/// <summary> /// Constructs an enumeration of all the selectable columns (i.e. all the columns corresponding to entity properties /// which are not part of a relationship). /// (e.g. Id, HouseNo, AptNo) /// </summary> protected virtual string ConstructColumnEnumerationForSelectInternal(string tableAlias = null) { return(string.Join(",", SelectProperties.Select(propInfo => GetColumnName(propInfo, tableAlias, true)))); }
protected GenericStatementSqlBuilder( EntityDescriptor entityDescriptor, EntityMapping entityMapping, SqlDialect dialect) { var databaseOptions = OrmConfiguration.Conventions.GetDatabaseOptions(dialect); UsesSchemaForTableNames = databaseOptions.IsUsingSchemas; IdentifierStartDelimiter = databaseOptions.StartDelimiter; IdentifierEndDelimiter = databaseOptions.EndDelimiter; ParameterPrefix = databaseOptions.ParameterPrefix; //_entityRelationships = new ConcurrentDictionary<IStatementSqlBuilder, EntityRelationship>(); _regularStatementFormatter = new SqlStatementFormatter(entityDescriptor, entityMapping, this, false); _forcedTableResolutionStatementFormatter = new SqlStatementFormatter(entityDescriptor, entityMapping, this, true); EntityDescriptor = entityDescriptor; EntityMapping = entityMapping; SelectProperties = EntityMapping.PropertyMappings .Select(propMapping => propMapping.Value) .ToArray(); KeyProperties = EntityMapping.PropertyMappings .Where(propMapping => propMapping.Value.IsPrimaryKey) .Select(propMapping => propMapping.Value) .OrderBy(propMapping => propMapping.ColumnOrder) .ToArray(); RefreshOnInsertProperties = SelectProperties .Where(propInfo => propInfo.IsRefreshedOnInserts) .ToArray(); RefreshOnUpdateProperties = SelectProperties .Where(propInfo => propInfo.IsRefreshedOnUpdates) .ToArray(); InsertKeyDatabaseGeneratedProperties = KeyProperties .Intersect(RefreshOnInsertProperties) .ToArray(); UpdateProperties = SelectProperties .Where(propInfo => !propInfo.IsExcludedFromUpdates) .ToArray(); InsertProperties = SelectProperties .Where(propInfo => !propInfo.IsExcludedFromInserts) .ToArray(); _noAliasTableName = new Lazy <string>(() => GetTableNameInternal(), LazyThreadSafetyMode.PublicationOnly); _noAliasKeysWhereClause = new Lazy <string>(() => ConstructKeysWhereClauseInternal(), LazyThreadSafetyMode.PublicationOnly); _noAliasKeyColumnEnumeration = new Lazy <string>(() => ConstructKeyColumnEnumerationInternal(), LazyThreadSafetyMode.PublicationOnly); _noAliasColumnEnumerationForSelect = new Lazy <string>(() => ConstructColumnEnumerationForSelectInternal(), LazyThreadSafetyMode.PublicationOnly); _columnEnumerationForInsert = new Lazy <string>(ConstructColumnEnumerationForInsertInternal, LazyThreadSafetyMode.PublicationOnly); _paramEnumerationForInsert = new Lazy <string>(ConstructParamEnumerationForInsertInternal, LazyThreadSafetyMode.PublicationOnly); _noAliasUpdateClause = new Lazy <string>(() => ConstructUpdateClauseInternal(), LazyThreadSafetyMode.PublicationOnly); _fullInsertStatement = new Lazy <string>(ConstructFullInsertStatementInternal, LazyThreadSafetyMode.PublicationOnly); _fullSingleUpdateStatement = new Lazy <string>(ConstructFullSingleUpdateStatementInternal, LazyThreadSafetyMode.PublicationOnly); _noConditionFullBatchUpdateStatement = new Lazy <string>(() => ConstructFullBatchUpdateStatementInternal(), LazyThreadSafetyMode.PublicationOnly); _fullSingleDeleteStatement = new Lazy <string>(ConstructFullSingleDeleteStatementInternal, LazyThreadSafetyMode.PublicationOnly); _noConditionFullBatchDeleteStatement = new Lazy <string>(() => ConstructFullBatchDeleteStatementInternal(), LazyThreadSafetyMode.PublicationOnly); _noConditionFullCountStatement = new Lazy <string>(() => ConstructFullCountStatementInternal(), LazyThreadSafetyMode.PublicationOnly); _fullSingleSelectStatement = new Lazy <string>(ConstructFullSingleSelectStatementInternal, LazyThreadSafetyMode.PublicationOnly); }