Beispiel #1
0
        public IOCreateEdge Set <T>(string fieldName, T fieldValue)
        {
            if (_document == null)
            {
                _document = new DictionaryOrientDBEntity();
            }
            _document.SetField(fieldName, fieldValue);

            return(this);
        }
        public IOCreateVertex Vertex(string className)
        {
            if (_document == null)
            {
                _document = new DictionaryOrientDBEntity();
            }

            _document.OClassName = className;

            return(this);
        }
Beispiel #3
0
        public static DictionaryOrientDBEntity ToDictionaryOrientDBEntity <T>(this T obj)
        {
            DictionaryOrientDBEntity entity = new DictionaryOrientDBEntity();
            var properties = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            foreach (var property in properties)
            {
                entity.SetField(property.Name, property.GetValue(obj));
            }
            return(entity);
        }
 public IOCreateDocument Document <T>(T obj)
 {
     if (obj is OrientDBEntity)
     {
         _document = (obj as OrientDBEntity).ToDictionaryOrientDBEntity();
     }
     else
     {
         _document = OrientDBEntityExtensions.ToDictionaryOrientDBEntity(obj);
     }
     return(this);
 }
Beispiel #5
0
 private void AppendORIDToField(DictionaryOrientDBEntity entity, string field, ORID orid)
 {
     if (entity.Fields.Keys.Contains(field))
     {
         entity.SetField(field, entity.GetField <HashSet <ORID> >(field).Add(orid));
     }
     else
     {
         var oridHashSet = new HashSet <ORID>();
         oridHashSet.Add(orid);
         entity.SetField(field, oridHashSet);
     }
 }
        public IOCreateVertex Vertex <T>(T obj)
        {
            if (obj is OrientDBEntity)
            {
                _document = (obj as OrientDBEntity).ToDictionaryOrientDBEntity();
            }
            else
            {
                _document = OrientDBEntityExtensions.ToDictionaryOrientDBEntity(obj);
            }

            if (string.IsNullOrEmpty(_document.OClassName))
            {
                throw new OrientDBException(OrientDBExceptionType.Query, "Document doesn't contain OClassName value.");
            }

            return(this);
        }
 public ORecordCreateDocument()
 {
     _document = new DictionaryOrientDBEntity();
 }
        public DocumentResult Execute(BinaryReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException($"{nameof(reader)} cannot be null.");
            }

            if (_connectionMetaData.ProtocolVersion > 26 && _connectionMetaData.UseTokenBasedSession)
            {
                ReadToken(reader);
            }

            PayloadStatus payloadStatus = (PayloadStatus)reader.ReadByte();

            List <DictionaryOrientDBEntity> documents = new List <DictionaryOrientDBEntity>();

            int contentLength;

            switch (payloadStatus)
            {
            case PayloadStatus.NullResult:     // 'n'
                                               // nothing to do
                break;

            case PayloadStatus.SingleRecord:     // 'r'
                DictionaryOrientDBEntity document = ParseDocument(reader);
                documents.Add(document);
                break;

            case PayloadStatus.SerializedResult:     // 'a'
                contentLength = reader.ReadInt32EndianAware();
                byte[] serializedBytes = reader.ReadBytes(contentLength);
                string serialized      = System.Text.Encoding.UTF8.GetString(serializedBytes, 0, serializedBytes.Length);

                break;

            case PayloadStatus.RecordCollection:     // 'l'

                int recordsCount = reader.ReadInt32EndianAware();

                for (int i = 0; i < recordsCount; i++)
                {
                    documents.Add(ParseDocument(reader));
                }
                break;

            case PayloadStatus.SimpleResult:     //'w'
                DictionaryOrientDBEntity sDocument = ParseDocument(reader);
                documents.Add(sDocument);
                break;

            default:
                break;
            }

            if (_connectionMetaData.ProtocolVersion >= 17)
            {
                //Load the fetched records in cache
                while ((payloadStatus = (PayloadStatus)reader.ReadByte()) != PayloadStatus.NoRemainingRecords)
                {
                    DictionaryOrientDBEntity document = ParseDocument(reader);

                    if (document != null && payloadStatus == PayloadStatus.PreFetched)
                    {
                        documents.Add(document);
                        //Put in the client local cache
                        //response.Connection.Database.ClientCache[document.ORID] = document;
                    }
                }
            }

            return(new DocumentResult(documents));
        }