Esempio n. 1
0
        public UrlsRepository(string virtualPathPrefix)
        {
            if (string.IsNullOrEmpty(virtualPathPrefix))
            {
                throw new ArgumentNullException("virtualPath");
            }

            this.VirtualPathPrefix = virtualPathPrefix.ToLower();

            FileLazy = GlobalLazy.WithoutInvalidations(() => new StaticContentResult(CreateFile(), fileName));
        }
Esempio n. 2
0
        private ResetLazy <HashSet <K> > GetAllKeysLazy <T, KVP, K>(Expression <Func <T, IEnumerable <KVP> > > collectionSelector, Expression <Func <KVP, K> > keySelector)
            where T : Entity
        {
            if (typeof(K).IsEnum)
            {
                return(new ResetLazy <HashSet <K> >(() => EnumExtensions.GetValues <K>().ToHashSet()));
            }

            if (typeof(K).IsLite())
            {
                return(GlobalLazy.WithoutInvalidations(() => Database.RetrieveAllLite(typeof(K).CleanType()).Cast <K>().ToHashSet()));
            }

            if (collectionSelector.Body.Type.IsMList())
            {
                var lambda = Expression.Lambda <Func <T, MList <KVP> > >(collectionSelector.Body, collectionSelector.Parameters);

                return(GlobalLazy.WithoutInvalidations(() => Database.MListQuery(lambda).Select(kvp => keySelector.Evaluate(kvp.Element)).Distinct().ToHashSet()));
            }
            else
            {
                return(GlobalLazy.WithoutInvalidations(() => Database.Query <T>().SelectMany(collectionSelector).Select(keySelector).Distinct().ToHashSet()));
            }
        }