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)); }
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); }
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); }
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)); }
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); }
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); }