/// <summary> /// /// </summary> /// <param name="api"></param> /// <param name="namespaceName"></param> /// <param name="name"></param> /// <param name="arguments"></param> /// <returns></returns> private static IQueryable SourceCore(this ApiBase api, string namespaceName, string name, object[] arguments) { var elementType = api.EnsureElementType(namespaceName, name); var method = SourceCoreMethod.MakeGenericMethod(elementType); var args = new object[] { namespaceName, name, arguments }; return(method.Invoke(null, args) as IQueryable); }
/// <summary> /// Gets a queryable source of data using an API context. /// </summary> /// <typeparam name="TElement"> /// The type of the elements in the queryable source. /// </typeparam> /// <param name="api"> /// An API. /// </param> /// <param name="name"> /// The name of an entity set, singleton or composable function import. /// </param> /// <param name="arguments"> /// If <paramref name="name"/> is a composable function import, /// the arguments to be passed to the composable function import. /// </param> /// <returns> /// A queryable source. /// </returns> /// <remarks> /// <para> /// If the name identifies a singleton or a composable function import /// whose result is a singleton, the resulting queryable source will /// be configured such that it represents exactly zero or one result. /// </para> /// <para> /// Note that the resulting queryable source cannot be synchronously /// enumerated, as the API engine only operates asynchronously. /// </para> /// </remarks> public static IQueryable <TElement> GetQueryableSource <TElement>(this ApiBase api, string name, params object[] arguments) { Ensure.NotNull(api, nameof(api)); Ensure.NotNull(name, nameof(name)); var elementType = api.EnsureElementType(null, name); if (typeof(TElement) != elementType) { throw new ArgumentException(Resources.ElementTypeNotMatch); } return(SourceCore <TElement>(null, name, arguments)); }