Example #1
0
        public ReadQueryOperation(Protobuf.Command command) : base(command.ToBuilder())
        {
            _readQueryCommand = command.ReadQueryCommand.ToBuilder();

            _query = new Query();

            _query = new Query
            {
                QueryText  = _readQueryCommand.Query.Query,
                Parameters = QueryParameterConverter.GetParameterList(_readQueryCommand.Query.ParametersList)
            };

            Message = this;
        }
Example #2
0
        internal override void BuildInternal()
        {
            var protobufQuery = new Protobuf.QueryBuilder.Builder();

            protobufQuery.Query = _query.QueryText;

            foreach (Parameter parameter in _query.Parameters)
            {
                Protobuf.Parameter.Builder protobufParameter = QueryParameterConverter.GetProtobufParameters(parameter);
                protobufQuery.ParametersList.Add(protobufParameter.Build());
            }

            _readQueryCommand.SetQuery(protobufQuery);



            _command.SetReadQueryCommand(_readQueryCommand);
            _command.SetType(Protobuf.Command.Types.Type.READ_QUERY);
        }
Example #3
0
        public WriteQueryOperation(Alachisoft.NosDB.Common.Protobuf.Command command) : base(command.ToBuilder())
        {
            _writeQueryCommand = command.WriteQueryCommand.ToBuilder();
            _query             = new Query();

            _query.QueryText = _writeQueryCommand.Query.Query;

            //foreach (Alachisoft.NosDB.Common.Protobuf.Parameter param in _writeQueryCommand.Query.ParametersList)
            //{
            //    switch ((ParameterType)param.JsonDataType)
            //    {
            //        case ParameterType.NULL:
            //            _query.Parameters.Add(new Parameter(param.Attribute, null));
            //            break;
            //        case ParameterType.BOOLEAN:
            //            _query.Parameters.Add(new Parameter(param.Attribute, bool.Parse(param.Value)));
            //            break;
            //        case ParameterType.DATETIME:
            //            _query.Parameters.Add(new Parameter(param.Attribute, DateTime.Parse(param.Value)));
            //            break;
            //        case ParameterType.STRING:
            //            _query.Parameters.Add(new Parameter(param.Attribute, param.Value));
            //            break;
            //        case ParameterType.LONG:
            //            _query.Parameters.Add(new Parameter(param.Attribute, long.Parse(param.Value)));
            //            break;
            //        case ParameterType.DOUBLE:
            //            _query.Parameters.Add(new Parameter(param.Attribute, double.Parse(param.Value)));
            //            break;
            //        case ParameterType.ARRAY:
            //            _query.Parameters.Add(new Parameter(param.Attribute, JsonConvert.DeserializeObject<JArray>(param.Value)));
            //            break;
            //        default:
            //            _query.Parameters.Add(new Parameter(param.Attribute, JSONDocument.Parse(param.Value)));
            //            break;
            //    }
            //}
            _query.Parameters = QueryParameterConverter.GetParameterList(_writeQueryCommand.Query.ParametersList);

            base.Message = this;
        }
Example #4
0
        internal override void BuildInternal()
        {
            Alachisoft.NosDB.Common.Protobuf.QueryBuilder.Builder protobufQuery = new Alachisoft.NosDB.Common.Protobuf.QueryBuilder.Builder();
            Alachisoft.NosDB.Common.Protobuf.Parameter.Builder    protobufParameter;

            protobufQuery.Query = _query.QueryText;

            foreach (Parameter parameter in _query.Parameters)
            {
                //protobufParameter = new Alachisoft.NosDB.Common.Protobuf.Parameter.Builder();
                //protobufParameter.Attribute = parameter.Name;

                //if(parameter.Value == null)
                //{
                //    protobufParameter.Value = "null";
                //    protobufParameter.JsonDataType = (int)ParameterType.NULL;
                //}
                //else
                //{
                //    protobufParameter.JsonDataType = (int)DataTypeMapper.MapDataType(parameter.Value);
                //    if (protobufParameter.JsonDataType == (int)ParameterType.ARRAY || protobufParameter.JsonDataType == (int)ParameterType.OBJECT)
                //        protobufParameter.Value = JsonConvert.SerializeObject(parameter.Value);
                //    else if (protobufParameter.JsonDataType == (int)ParameterType.JSONDOCUMENT)
                //        protobufParameter.Value= parameter.Value.ToString();
                //    else
                //        protobufParameter.Value = parameter.Value.ToString();
                //}
                protobufParameter = QueryParameterConverter.GetProtobufParameters(parameter);
                protobufQuery.ParametersList.Add(protobufParameter.Build());
            }

            _writeQueryCommand.SetQuery(protobufQuery);


            base._command.SetWriteQueryCommand(_writeQueryCommand);
            base._command.SetType(Alachisoft.NosDB.Common.Protobuf.Command.Types.Type.WRITE_QUERY);
        }