#pragma warning disable 1591 // Xml Comments public QueryResult Execute(IQuery query, PagingInfo paging) { ThrowIfNoQueryPropertyOnQuery(query); var result = new QueryResult(); try { var property = GetQueryPropertyFromQuery(query); var queryProviderType = GetActualProviderTypeFrom(property.PropertyType); ThrowIfUnknownQueryType(queryProviderType, query, property); var provider = _container.Get(queryProviderType); var actualQuery = property.GetValue(query, null); var providerResult = ExecuteOnProvider(provider, actualQuery, paging); result.TotalItems = providerResult.TotalItems; result.Items = providerResult.Items; } catch (TargetInvocationException ex) { result.Exception = ex.InnerException; } catch (Exception ex) { result.Exception = ex; } return result; }
void AddClientTypeInformation(QueryResult result) { var items = new List<object>(); foreach (var item in result.Items) { var dynamicItem = item.AsExpandoObject(); var type = item.GetType(); if (_configuration.NamespaceMapper.CanResolveToClient(type.Namespace)) dynamicItem._sourceType = string.Format("{0}.{1}", _configuration.NamespaceMapper.GetClientNamespaceFrom(type.Namespace), type.Name.ToCamelCase()); items.Add(dynamicItem); } result.Items = items; }
/// <summary> /// Creates a <see cref="QueryResult"/> for a given <see cref="IQuery"/> /// </summary> /// <param name="query"><see cref="IQuery"/> to create for</param> /// <returns><see cref="QueryResult"/> for the given <see cref="IQuery"/></returns> public static QueryResult For(IQuery query) { var result = new QueryResult { QueryName = query.GetType().Name }; return result; }