Esempio n. 1
0
        public IPagedGraphCollection <TAggregate> ExecuteWithPaging(IGraphSession session, IQuery <TAggregate> query, bool enlist)
        {
            var dataset = Execute(query);

            if (!dataset.Any())
            {
                return(new PagedGraphGraphCollection <TAggregate>());
            }
            var total   = dataset.First().Total;
            var page    = total == 0 ? 1 : query.Skip / total + 1;
            var results = Map(item =>
            {
                var aggregate = item.Create();
                if (session.Uow.Contains(aggregate))
                {
                    aggregate = session.Uow.Get <TAggregate>(ProxyUtils.GetEntityId(aggregate));
                }
                else if (enlist)
                {
                    aggregate = session.ProxyFactory.Create(aggregate, session);
                }
                return(aggregate);
            }, dataset);

            return(new PagedGraphGraphCollection <TAggregate>(session, this, query, results, (int)total, (int)page, enlist));
        }
Esempio n. 2
0
            private string EnsureIdIsNotNull(object item)
            {
                var id = ProxyUtils.GetEntityId(item);

                if (string.IsNullOrEmpty(id))
                {
                    throw new PropertyNotSetException($"The entity identified \"{Conventions.IdPropertyName}\" cannot be null or empty", item);
                }
                return(id);
            }
Esempio n. 3
0
            private List <object> ProxyListItems(IList <object> source)
            {
                var destination = new List <object>();

                for (int i = 0; i < source.Count; i++)
                {
                    var type     = ProxyUtils.GetTargetType(source[i]);
                    var existing = _session.Uow.Get(ProxyUtils.GetEntityId(source[i]), type);
                    var child    = existing ?? Create(type, source[i]);
                    destination.Add(child);
                }
                return(destination);
            }
Esempio n. 4
0
            private object Entity(NodeMetadata metadata, PropertyInfo property, object item, object parent)
            {
                var propertyMetadata = _metadataFactory.Create(item);

                if (propertyMetadata.IsIgnored)
                {
                    return(item);
                }

                var type   = ProxyUtils.GetTargetType(item);
                var entity = _session.Uow.Get(ProxyUtils.GetEntityId(item), type) ?? item;

                return(Create(type, entity));
            }
Esempio n. 5
0
        public IEnumerable <TAggregate> Execute(IGraphSession session, IQuery <TAggregate> query)
        {
            var dataset = Execute(query);
            var results = Map(item =>
            {
                var aggregate = item.Create();
                if (session.Uow.Contains(aggregate))
                {
                    aggregate = session.Uow.Get <TAggregate>(ProxyUtils.GetEntityId(aggregate));
                }
                return(aggregate);
            }, dataset);

            return(results);
        }
Esempio n. 6
0
        public ICypherQuery Execute(ICypherQuery query)
        {
            var node  = StatementFactory.Parameter(_node);
            var id    = StatementFactory.IdParameter(_node);
            var merge = StatementFactory.Merge(_node, id);
            var set   = StatementFactory.Set(_node, node);

            query = query
                    .Merge(merge)
                    .OnCreate()
                    .Set(set)
                    .OnMatch()
                    .Set(set)
                    .WithParam(node, _factory().ToDictionary())
                    .WithParam(id, ProxyUtils.GetEntityId(_node));
            return(query);
        }