We're updating the issue view to help you get more done. 

Add IExecutableQuery<out T>

Description

  • Add IExecutableQuery<out T>, derived from IQuery. (In Remotion.Data.Linq namespace.)

    • Represents a query that can be executed using an IQueryManager.

    • T is the type of the query result.

    • Method: T Execute (IQueryManager queryManager).

  • Add a QueryAdapterBase<T> : IExecutableQuery<T>

    • Abstract class that aids in implementing IExecutableQuery<T> based on existing IQuery objects.

    • Takes an inner IQuery and implements all IExecutableQuery<T> members by delegating to the inner query.

    • Execute remains abstract.

    • For the unit tests, derive a TestableQueryAdapterBase<T> class that implements Executable by throwing a NotImplementedException.

    • Tip: Use DecoratorTestHelper to test this class.

  • Add ScalarQueryAdapter<T> : QueryAdapterBase<T>

    • Adapts a scalar query to implement the IExecutableQuery interface.

    • Takes an IQuery, and a Func<object, T> resultConversion. Check that the IQuery has QueryType.Scalar.

    • Execute calls ExecuteScalar with "this" on the query manager, then converts the result to T via the result conversion delegate.

  • DomainObjectSequenceQueryAdapter<TItem> : QueryAdapterBase<IEnumerable<TItem>>

    • Adapts a query returning a sequence of DomainObjects to implement the IExecutableQuery interface.

    • Takes an IQuery and delegates all methods to that inner query. Check that the IQuery has QueryType.Collection.

    • Execute simply calls the non-generic ExecuteCollection method on the query manager (with "this"), calls "AsEnumerable" on the result, then uses "Cast" to convert the result items to type TItem.

  • CustomSerquenceQueryAdapter<TItem> : QueryAdapterBase<IEnumerable<TItem>>

    • Adapts a query with a custom projection to implement the IExecutableQuery interface.

    • Takes an IQuery and delegates all methods to that inner query. Check that the query has QueryType.Custom.

    • Takes a Func<IQueryResultRow, TResultItem> _resultConversion.

    • Execute calls queryManager.ExecuteCustom<TResultItem>, and passes in the result conversion delegate.

Assignee

Fabian Schmied

Reporter

Fabian Schmied

Labels

None

Time tracking

2h

Components

Fix versions

Priority

Normal
Configure