示例#1
0
        /// <inheritdoc />
        public virtual IQueryable <TViewModel> GetAll <TViewModel>(string connectorName, string tableName, ILoggingService loggingService = null)
        {
            loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.GET);
            IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, tableName);

            //Manually $expand to prevent nulls on non pk joins
            var joinProperties = typeof(TViewModel).GetProperties()
                                 .Where(c => (c.PropertyType.IsClass && c.PropertyType != typeof(string)) ||
                                        (c.PropertyType.IsGenericType && c.PropertyType.GetGenericTypeDefinition() == typeof(IEnumerable <>)))
                                 .Select(c => c.Name);

            IQueryable <dynamic> list;

            if (joinProperties.Any())
            {
                list = resource.GetResourceRecords(new Dictionary <string, string>()
                {
                    { "$expand", string.Join(",", joinProperties) }
                });
            }
            else
            {
                list = resource.GetResourceRecords(new Dictionary <string, string>());
            }

            return(list.ProjectTo <TViewModel>());
        }
示例#2
0
        /// <inheritdoc />
        public virtual (IQueryable <object> list, int connectorMax) GetAll(string connectorName, string tableName, ILoggingService loggingService = null)
        {
            Check.NotEmpty(connectorName, nameof(connectorName));
            Check.NotEmpty(tableName, nameof(tableName));

            loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.GET);
            IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, tableName);

            var queryString = _requestQuery.GetQueryStrings();

            return(resource.GetResourceRecords(queryString), resource.Connector.RecordLimit);
        }