コード例 #1
0
        public string Run()
        {
            OCluster cluster;
            var      defaultClusterId = _connection.Database.GetClusterIdFor(_className);

            if (defaultClusterId == -1)
            {
                CommandPayloadCommand payload = new CommandPayloadCommand();
                payload.Text = ToString();

                Command operation = new Command(_connection.Database);
                operation.OperationMode  = OperationMode.Synchronous;
                operation.CommandPayload = payload;
                var            doc    = _connection.ExecuteOperation(operation);
                OCommandResult result = new OCommandResult(doc);
//                var clusterId = short.Parse(result.ToDocument().GetField<string>("Content"));

                cluster = _connection.Database.AddCluster(new OCluster {
                    Name = _className
                });
            }
            else
            {
                cluster = _connection.Database.GetClusters().FirstOrDefault(c => c.Name == _className);
            }

            if (_autoProperties)
            {
                CreateAutoProperties();
            }

            return(cluster.Name);
        }
コード例 #2
0
        private OCommandResult RunInternal()
        {
            try
            {
                if (_parameters == null)
                {
                    throw new ArgumentNullException("_parameters");
                }

                var paramsDocument = new ODocument();
                paramsDocument.OClassName = "";
                paramsDocument.SetField(OClient.ProtocolVersion < 22 ? "params" : "parameters", _parameters);

                var serializer = RecordSerializerFactory.GetSerializer(_connection.Database);


                CommandPayloadCommand payload = new CommandPayloadCommand();
                payload.Text         = ToString();
                payload.SimpleParams = serializer.Serialize(paramsDocument);

                Command operation = new Command(_connection.Database);
                operation.OperationMode  = OperationMode.Synchronous;
                operation.CommandPayload = payload;

                ODocument document = _connection.ExecuteOperation(operation);

                return(new OCommandResult(document));
            }
            finally
            {
                _parameters = null;
            }
        }
コード例 #3
0
        public OCommandResult Command(string sql)
        {
            CommandPayloadCommand payload = new CommandPayloadCommand();

            payload.Text = sql;

            OCommandQuery query = new OCommandQuery(GetConnection(), payload);

            return(query.Run());
        }
コード例 #4
0
        public ODocument Run()
        {
            CommandPayloadCommand payload = new CommandPayloadCommand();

            payload.Text = ToString();

            Command operation = new Command(_connection.Database);

            operation.OperationMode  = OperationMode.Synchronous;
            operation.CommandPayload = payload;

            OCommandResult result = new OCommandResult(_connection.ExecuteOperation(operation));

            return(result.ToSingle());
        }
コード例 #5
0
        public int Run()
        {
            CommandPayloadCommand payload = new CommandPayloadCommand();

            payload.Text = ToString();

            Command operation = new Command(_connection.Database);

            operation.OperationMode  = OperationMode.Synchronous;
            operation.CommandPayload = payload;

            OCommandResult result = new OCommandResult(_connection.ExecuteOperation(operation));

            return(int.Parse(result.ToDocument().GetField <string>("Content")));
        }
コード例 #6
0
        public OCommandResult Command(string sql)
        {
            CommandPayloadCommand payload = new CommandPayloadCommand();

            payload.Text = sql;

            Command operation = new Command(_connection.Database);

            operation.OperationMode  = OperationMode.Synchronous;
            operation.CommandPayload = payload;

            ODocument document = _connection.ExecuteOperation(operation);

            return(new OCommandResult(document));
        }
コード例 #7
0
        public short Run()
        {
            if (string.IsNullOrEmpty(_class))
            {
                throw new OException(OExceptionType.Query, "Class is empty");
            }

            CommandPayloadCommand payload = new CommandPayloadCommand();

            payload.Text = ToString();

            Command operation = new Command(_connection.Database);

            operation.OperationMode  = OperationMode.Synchronous;
            operation.CommandPayload = payload;

            OCommandResult result = new OCommandResult(_connection.ExecuteOperation(operation));

            return(short.Parse(result.ToDocument().GetField <string>("Content")));
        }