private List <BaseModel> LoadModelCollection(List <Dictionary <string, object> > dataCollection, ExpressionMetadataChain chain)
        {
            var method = RepositoryReflectionUtilities.GetGenericMethod(GetType(),
                                                                        "LoadTypedModelCollection", chain.GetModelType());
            var models = (List <BaseModel>)method?.Invoke(this, new object[] { dataCollection });

            return(models);
        }
        private IEnumerable <T> ApplyCollectionProjector <T>(IReadOnlyCollection <object> sourceItems, ExpressionMetadataChain chain)
        {
            var notAppliedChainItems = chain.Items.Where(x => !x.IsAppliedToQuery).ToList();

            if (notAppliedChainItems.Any())
            {
                var method = RepositoryReflectionUtilities.GetGenericMethod(this.GetType(), "ApplyTypedCollectionProjector", typeof(T),
                                                                            notAppliedChainItems.First().InputDtoType.Type);
                return((IEnumerable <T>)method.Invoke(this, new object[] { sourceItems, chain }));
            }
            return(sourceItems.Select(x => (T)x).AsEnumerable());
        }
Example #3
0
        private static List <object> GetRightValuesList(Expression collectionExpression, Type converterType, Type valueType)
        {
            if (!TryDynamicInvoke(collectionExpression, out var collection))
            {
                return(null);
            }
            var method = RepositoryReflectionUtilities.GetGenericMethod(converterType, "ConvertCollectionToObjectList",
                                                                        valueType);
            var list = (List <object>)method.Invoke(null, new object[] { collection });

            return(list);
        }
        private T ApplyScalarProjector <T>(List <object> sourceItems, ExpressionMetadataChain chain)
        {
            var notAppliedChainItems = chain.Items.Where(x => !x.IsAppliedToQuery).ToList();

            if (!notAppliedChainItems.Any())
            {
                return(sourceItems.Any() ? (T)sourceItems.First() : default(T));
            }
            var method = RepositoryReflectionUtilities.GetGenericMethod(this.GetType(), "ApplyTypedScalarProjector", typeof(T),
                                                                        notAppliedChainItems.First().InputDtoType.Type);

            return((T)method.Invoke(this, new object[] { sourceItems, chain }));
        }
        public IEnumerable ExecuteEnumerable(Type type, Expression expression)
        {
            var method = RepositoryReflectionUtilities.GetGenericMethod(this.GetType(), "ExecuteEnumerable", type);

            return((IEnumerable)method.Invoke(this, new object[] { expression }));
        }