Пример #1
0
        public TResult[] Load <TResult>(IEnumerable <string> ids, Type transformerType, Action <ILoadConfiguration> configure = null)
        {
            var configuration = new RavenLoadConfiguration();

            if (configure != null)
            {
                configure(configuration);
            }

            var transformer = ((AbstractTransformerCreationTask)Activator.CreateInstance(transformerType)).TransformerName;

            return(LoadInternal <TResult>(ids.ToArray(), transformer, configuration.TransformerParameters));
        }
Пример #2
0
        public TResult Load <TResult>(string id, Type transformerType, Action <ILoadConfiguration> configure = null)
        {
            var configuration = new RavenLoadConfiguration();

            if (configure != null)
            {
                configure(configuration);
            }

            var transformer = ((AbstractTransformerCreationTask)Activator.CreateInstance(transformerType)).TransformerName;

            return(LoadInternal <TResult>(new[] { id }, transformer, configuration.TransformerParameters).FirstOrDefault());
        }
Пример #3
0
        Lazy <TResult> ILazySessionOperations.Load <TResult>(string id, Type transformerType, Action <ILoadConfiguration> configure, Action <TResult> onEval)
        {
            var transformer   = ((AbstractTransformerCreationTask)Activator.CreateInstance(transformerType)).TransformerName;
            var ids           = new[] { id };
            var configuration = new RavenLoadConfiguration();

            if (configure != null)
            {
                configure(configuration);
            }

            var lazyLoadOperation = new LazyTransformerLoadOperation <TResult>(
                ids,
                transformer,
                configuration.TransformerParameters,
                new LoadTransformerOperation(this, transformer, ids),
                singleResult: true);

            return(AddLazyOperation(lazyLoadOperation, onEval));
        }
Пример #4
0
        Lazy <TResult> ILazySessionOperations.Load <TTransformer, TResult>(string id, Action <ILoadConfiguration> configure, Action <TResult> onEval)
        {
            var transformer   = new TTransformer().TransformerName;
            var ids           = new[] { id };
            var configuration = new RavenLoadConfiguration();

            if (configure != null)
            {
                configure(configuration);
            }

            var lazyLoadOperation = new LazyTransformerLoadOperation <TResult>(
                ids,
                transformer,
                configuration.TransformerParameters,
                new LoadTransformerOperation(this, transformer, ids),
                singleResult: true);

            return(AddLazyOperation(lazyLoadOperation, onEval));
        }
Пример #5
0
        public TResult[] LoadStartingWith <TTransformer, TResult>(string keyPrefix, string matches = null, int start = 0,
                                                                  int pageSize = 25, string exclude = null,
                                                                  RavenPagingInformation pagingInformation = null,
                                                                  Action <ILoadConfiguration> configure    = null)
            where TTransformer : AbstractTransformerCreationTask, new()
        {
            var transformer = new TTransformer().TransformerName;

            var configuration = new RavenLoadConfiguration();

            if (configure != null)
            {
                configure(configuration);
            }

            return
                (DatabaseCommands.StartsWith(keyPrefix, matches, start, pageSize, exclude: exclude,
                                             pagingInformation: pagingInformation, transformer: transformer, queryInputs: configuration.QueryInputs)
                 .Select(TrackEntity <TResult>)
                 .ToArray());
        }
Пример #6
0
        Lazy <TResult[]> ILazySessionOperations.Load <TResult>(IEnumerable <string> ids, Type transformerType, Action <ILoadConfiguration> configure, Action <TResult> onEval)
        {
            var transformer = ((AbstractTransformerCreationTask)Activator.CreateInstance(transformerType)).TransformerName;

            var configuration = new RavenLoadConfiguration();

            if (configure != null)
            {
                configure(configuration);
            }

            var idsArray = ids.ToArray();

            var lazyLoadOperation = new LazyTransformerLoadOperation <TResult>(
                idsArray,
                transformer,
                configuration.TransformerParameters,
                new LoadTransformerOperation(this, transformer, idsArray),
                singleResult: false);

            return(AddLazyOperation <TResult[]>(lazyLoadOperation, null));
        }