public void ConstructorThrowsIfStringIsNull() { ISelectSetup <UserEntity, UserDto> setup = DummyQuery <UserEntity>() .Select <UserDto>(); Assert.That(() => new SelectSetupPart <UserEntity, UserDto>(null, setup, null), Throws.ArgumentException); }
public void CanConstruct() { ISelectSetup <UserEntity, UserDto> setup = DummyQuery <UserEntity>() .Select <UserDto>(); var part = new SelectSetupPart <UserEntity, UserDto>("IsOnline", setup, null); Assert.That(part, Is.Not.Null); }
/// <summary> /// Specifies a <see cref="ISelectSetup{TSource, TDestination}" /> to project. /// </summary> /// <param name="setup"> /// The setup. /// </param> /// <typeparam name="TDestination"> /// The <see cref="System.Type" /> of the result. /// </typeparam> /// <returns> /// The <see cref="T:TQuery" />. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="setup" /> is null. /// </exception> protected virtual TQuery Project <TDestination>(ISelectSetup <TSource, TDestination> setup) { if (setup == null) { throw new ArgumentNullException("setup"); } return(ProjectionBase <TDestination>(setup.ProjectionList, setup.Mappings)); }
/// <inheritdoc /> public virtual void Select <TDestination> ( IResultStream <TDestination> stream, ISelectSetup <TSource, TDestination> setup ) { Project(setup); SelectStream(stream); }
/// <inheritdoc /> public virtual Lazy <Dictionary <TKey, TValue> > SelectDictionary <TKey, TValue> ( Expression <Func <TSource, TKey> > key, Expression <Func <TSource, TValue> > value ) { ISelectSetup <TSource, Pair <TKey, TValue> > setup = Select <Pair <TKey, TValue> >() .For(x => x.Key).Use(key) .For(x => x.Value).Use(value); Project(setup); return(SelectDelayedDictionary <TKey, TValue>()); }
public void CanStreamAllUsersGivenSelectSetupIsSpecified() { var stream = new DummyResultStream <UserEntity, UserDto>(); IImmediateFlowQuery <UserEntity> query = Query <UserEntity>(); ISelectSetup <UserEntity, UserDto> setup = query .Select <UserDto>() .For(x => x.Fullname).Use(x => x.Firstname + " " + x.Lastname) .For(x => x.Id).Use(x => x.Id); query .Streamed() .Select(stream, setup); Assert.That(stream.Items.Count, Is.EqualTo(4)); }
/// <summary> /// Initializes a new instance of the <see cref="SelectSetupPart{TSource,TDestination}" /> class. /// </summary> /// <param name="forProperty"> /// The property name. /// </param> /// <param name="setup"> /// The <see cref="ISelectSetup{TSource, TDestination}" /> instance. /// </param> /// <param name="data"> /// The <see cref="QueryHelperData" /> instance. /// </param> /// <exception cref="ArgumentException"> /// <paramref name="forProperty" /> is null or <see cref="string.Empty" />. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="setup" /> is null. /// </exception> public SelectSetupPart(string forProperty, ISelectSetup <TSource, TDestination> setup, QueryHelperData data) { if (string.IsNullOrEmpty(forProperty)) { throw new ArgumentException("forProperty"); } if (setup == null) { throw new ArgumentNullException("setup"); } Data = data; ForProperty = forProperty; Setup = setup; }
/// <inheritdoc /> public virtual FlowQuerySelection <TDestination> Select <TDestination>(ISelectSetup <TSource, TDestination> setup) { Project(setup); return(SelectList <TDestination>()); }
public void CanConstruct() { ISelectSetup <UserEntity, UserDto> setup = CreateSetup(); Assert.That(setup, Is.Not.Null); }