Ejemplo n.º 1
0
 /// <summary>
 /// Wrap the DSPLinqQuery with a PagedQueryProvider
 /// </summary>
 /// <param name="source">The DSPLinqQuery Instance</param>
 /// <returns>A new queryable which supports paging</returns>
 private IQueryable WrapWithPagingProvider(IQueryable source)
 {
     if (customPagingEnabled)
     {
         IQueryProvider provider = new AstoriaUnitTests.Tests.PagedQueryProvider(
             this,
             source.Provider,
             null,
             null,
             new AstoriaUnitTests.Tests.CountManager());
         return(DSPLinqQueryProvider.CreateQuery(provider, source.Expression));
     }
     else
     {
         return(source);
     }
 }
Ejemplo n.º 2
0
        /// <summary>Invokes the specified service operation.</summary>
        /// <param name="serviceOperation">The service operation to invoke.</param>
        /// <param name="parameters">The parameters for the service operation. Their types will match the types of the declared parameters for the service operation.</param>
        /// <returns>The result of the service operation.
        /// If the service operation is declared to return void, this method should return null.
        /// Otherwise the method should return object of the type declared as the return type for the service operation.</returns>
        public object InvokeServiceOperation(ServiceOperation serviceOperation, object[] parameters)
        {
            Func <Object[], Object> operation;

            if (this.dataSource.ServiceOperations.TryGetValue(serviceOperation.Name, out operation))
            {
                object result = operation(parameters);
                if (result is IQueryable)
                {
                    // in order to further compose on top of this query, we need to turn this into a DSPLinqQuery
                    return(WrapWithPagingProvider(DSPLinqQueryProvider.CreateQuery((IQueryable)result)));
                }

                return(result);
            }

            throw new InvalidOperationException("Specified service operation is not implemented by the data source");
        }
Ejemplo n.º 3
0
        /// <summary>Helper strongly typed method to create the query for a resource set root.</summary>
        /// <typeparam name="TElement">The instance type of a single resource in the set.</typeparam>
        /// <param name="resourceSet">The resource set to get the query root for.</param>
        /// <returns>Strongly typed query for the resource set root.</returns>
        private System.Linq.IQueryable GetTypedQueryRootForResourceSet <TElement>(ResourceSet resourceSet)
        {
            IQueryable source = DSPLinqQueryProvider.CreateQuery(this.dataSource.GetResourceSetEntities(resourceSet.Name).Cast <TElement>().AsQueryable());

            return(WrapWithPagingProvider(source));
        }