/// <summary> /// Selects entities whose entityKey member is contained within the request's requestItems collection /// ie: Where(entity => request.requestItems.Contains(entity.entityKey)) /// </summary> public static BulkRequestEntityConfigBuilder <TRequest, TItem, TEntity> SelectBy <TRequest, TItem, TEntity>( this BulkRequestEntityConfigBuilder <TRequest, TItem, TEntity> config, Expression <Func <TRequest, ICollection <TItem> > > requestItems, string entityKey) where TEntity : class { var kEntity = Key.MakeKey <TEntity>(entityKey); var kItem = Key.Identity <TItem>(); var selector = SelectorHelpers.BuildCollection <TRequest, TItem, TEntity>(requestItems, kEntity, kItem); return(config.SetSelector(selector)); }
/// <summary> /// Selects entities whose entityKey member is contained within the request's requestItems collection /// ie: Where(entity => request.requestItems.Contains(entity.entityKey)) /// </summary> public static BulkRequestEntityConfigBuilder <TRequest, TItem, TEntity> SelectBy <TRequest, TItem, TEntity>( this BulkRequestEntityConfigBuilder <TRequest, TItem, TEntity> config, Expression <Func <TRequest, ICollection <TItem> > > requestItems, Expression <Func <TEntity, TItem> > entityKey) where TEntity : class { var kEntity = Key.MakeKeys(entityKey); var kItem = Key.Identity <TItem>(); if (kEntity.Length > 1) { throw new BadConfigurationException($"Composite keys are not supported for bulk requests"); } var selector = SelectorHelpers.BuildCollection <TRequest, TItem, TEntity>(requestItems, kEntity[0], kItem); return(config.SetSelector(selector)); }
private void BuildDefaultSelector <TCompatibleRequest>(RequestConfig <TCompatibleRequest> config) { var kItem = config.GetRequestKeys(); var kEntity = config.GetKeysFor <TEntity>(); if (kItem != null && kItem.Length > 0 && kEntity != null && kItem.Length > 0) { if (kItem.Length != kEntity.Length) { throw new IncompatibleKeysException(typeof(TCompatibleRequest), typeof(TEntity)); } if (kItem.Length > 1) { throw new BadConfigurationException($"Composite keys are not supported for bulk requests"); } var selector = SelectorHelpers.BuildCollection <TRequest, TItem, TEntity>( _getRequestItems, kEntity[0], kItem[0]); config.SetEntitySelector <TEntity>(selector); } }