public Edge([NotNull] IGraphEntity sourceGraphEntity, [NotNull] IGraphEntity targetGraphEntity,
             IEnumerable <IGraphSerializable>?attributes = null)
     : base($"{sourceGraphEntity.GraphId}::{targetGraphEntity.GraphId}")
 {
     _sourceGraphEntity = sourceGraphEntity;
     _targetGraphEntity = targetGraphEntity;
     _attributes        = attributes ?? new IGraphSerializable[0];
 }
Example #2
0
            private IGraphEntity LoadGraphEntity(string propertyName, JToken record, Dictionary <string, object> itemproperties,
                                                 Type propertyType)
            {
                IGraphEntity graphEntity         = null;
                var          entityPropertyNames = new EntityReturnColumns(propertyName);

                AssertNecesaryColumnForType(entityPropertyNames.IdPropertyName, typeof(IGraphEntity));

                var recordIsArray = record.GetType().IsAssignableFrom(typeof(JArray));
                var entityId      = recordIsArray
                    ? record[_propertyCache[entityPropertyNames.IdPropertyName]].Value <long>() :
                                    record["row"][_propertyCache[entityPropertyNames.IdPropertyName]].Value <long>();

                if (_cache.Contains(entityId, propertyType))
                {
                    graphEntity = _cache.GetEntity(entityId, propertyType);
                }
                else
                {
                    itemproperties.Add("id", entityId);

                    AssertNecesaryColumnForType(entityPropertyNames.PropertiesPropertyName, typeof(IGraphEntity));
                    var entityProperties =
                        recordIsArray
                            ? record[_propertyCache[entityPropertyNames.PropertiesPropertyName]]
                        .ToObject <Dictionary <string, object> >() :
                        record["row"][_propertyCache[entityPropertyNames.PropertiesPropertyName]].ToObject <Dictionary <string, object> >();
                    itemproperties.Add("properties", entityProperties);

                    if (typeof(Node).IsAssignableFrom(propertyType))
                    {
                        AssertNecesaryColumnForType(entityPropertyNames.LabelsPropertyName, typeof(Node));
                        var labels = entityProperties.Keys.ToArray();
                        itemproperties.Add("labels", labels);
                    }
                    else
                    {
                        AssertNecesaryColumnForType(entityPropertyNames.TypePropertyName,
                                                    typeof(Relationship));
                        var relType = recordIsArray ?
                                      record[_propertyCache[entityPropertyNames.TypePropertyName]].ToObject <string>() :
                                      record["row"][_propertyCache[entityPropertyNames.TypePropertyName]].ToObject <string>();
                        itemproperties.Add("type", relType);
                    }

                    graphEntity = (IGraphEntity)HydrateWithCtr(itemproperties, propertyType);
                    _cache.CacheEntity(graphEntity);
                }
                return(graphEntity);
            }
Example #3
0
        public void CacheEntity(IGraphEntity entity)
        {
            var entType = entity.GetType();

            if (Contains(entity.Id, entType))
            {
                throw new Exception("Entry already exists in the cache");
            }
            var useExistingDictionary = _inner.ContainsKey(entity.Id);
            var dic = useExistingDictionary
                          ? _inner[entity.Id]
                          : new Dictionary <Type, IGraphEntity>();

            dic[entType] = entity;
            if (!useExistingDictionary)
            {
                _inner.Add(entity.Id, dic);
            }
        }
Example #4
0
 public static void Set <TProp>(
     [ArgumentEvaluator(typeof(MemberNameArgumentEvaluator))] this IGraphEntity entity, string propName,
     [ArgumentEvaluator(typeof(StringWrapperArgumentEvaluator))] TProp value)
 {
     throw new ExpressionTreeOnlyUsageException();
 }
Example #5
0
 public static object Get(
     [ArgumentEvaluator(typeof(MemberNameArgumentEvaluator))] this IGraphEntity entity, string propName)
 {
     throw new ExpressionTreeOnlyUsageException();
 }
 public Node([NotNull] IGraphEntity graphEntity, IEnumerable<IGraphSerializable>? attributes = null)
     : base(graphEntity.GraphId)
 {
     _graphEntity = graphEntity;
     _attributes = attributes ?? new IGraphSerializable[0];
 }
Example #7
0
 public GraphEdge(IGraphEntity root, IGraphEntity leaf)
 {
     this.Root = root;
     this.Leaf = leaf;
 }
Example #8
0
 public static long Id(
     [ArgumentEvaluator(typeof(MemberNameArgumentEvaluator))] IGraphEntity relationshipReference)
 {
     throw new NotImplementedException();
 }
Example #9
0
 public static bool Has(
     [ArgumentEvaluator(typeof(MemberNameArgumentEvaluator))] IGraphEntity relationshipReference,
     string property)
 {
     throw new NotImplementedException();
 }